mirror of
https://github.com/Afilmory/afilmory
synced 2026-02-01 22:48:17 +00:00
- 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>
27 lines
515 B
JavaScript
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
|
|
}
|
|
}
|