Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lunaria/prepare-json-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async function mergeLocale(locale: LocaleObject): Promise<void> {

await fs.writeFile(
path.resolve(`${destFolder}/${locale.code}.json`),
JSON.stringify(source, null, 2),
`${JSON.stringify(source, null, 2)}\n`,
'utf-8',
)
}
24 changes: 24 additions & 0 deletions scripts/compare-translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,30 @@ const processLocale = async (
): Promise<SyncStats> => {
const filePath = join(LOCALES_DIRECTORY, localeFile)
const localeInfo = checkJsonName(filePath)

if (fix) {
// prevent update
// country locale file: e.g. es or es-ES
if (localeInfo.forCountry) {
// prevent adding missing keys to target locale: e.g. es-ES
// in this case i18n will do the work for us, the target locale should be empty
if (localeInfo.mergeLocale) {
console.error(
`${COLORS.red}Error: Locale "${localeInfo.locale}" cannot be fixed, fix the ${localeInfo.lang} locale instead!${COLORS.reset}`,
)
process.exit(1)
}
}
// prevent fix country locale, i18n will merge lang file and the target locale:
// e.g. es-419: i18n will merge es and es-419 for us
else if (localeInfo.mergeLocale) {
console.error(
`${COLORS.red}Error: Locale "${localeInfo.locale}" cannot be fixed.!${COLORS.reset}`,
)
process.exit(1)
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

const targetContent = await loadJson(localeInfo)

const stats: SyncStats = {
Expand Down
Loading