Files
afilmory/plugins/eslint/utils.js
Innei c775f82153 feat(i18n): integrate i18next for internationalization support
- Added i18next and react-i18next for multi-language support in the application.
- Created localization files for English, Japanese, Korean, Traditional Chinese, and Simplified Chinese.
- Implemented translation hooks in various components to replace hardcoded strings with translatable keys.
- Updated ESLint configuration to include new i18n JSON validation rules.
- Introduced a new event bus for handling i18n updates during development.

Signed-off-by: Innei <tukon479@gmail.com>
2025-06-12 17:56:11 +08:00

27 lines
515 B
JavaScript

export const sortObjectKeys = (obj) => {
if (typeof obj !== 'object' || obj === null) {
return obj
}
if (Array.isArray(obj)) {
return obj.map((element) => sortObjectKeys(element))
}
return Object.keys(obj)
.sort()
.reduce((acc, key) => {
acc[key] = sortObjectKeys(obj[key])
return acc
}, {})
}
export const cleanJsonText = (text) => {
const cleaned = text.replaceAll(/,\s*\}/g, '}')
try {
JSON.parse(cleaned)
return cleaned
} catch {
return text
}
}