Skip to content

Commit

Permalink
refactor: reduce console noise about iso deprecation (#3079)
Browse files Browse the repository at this point in the history
Co-authored-by: Bobbie Goede <[email protected]>
  • Loading branch information
reslear and BobbieGoede committed Sep 5, 2024
1 parent 7ccaf16 commit 571a510
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ export type LocaleConfig = {
*/
export const mergeConfigLocales = (configs: LocaleConfig[], baseLocales: LocaleObject[] = []) => {
const mergedLocales = new Map<string, LocaleObject>()
const deprecatedIsolocales = new Set<string>()

for (const locale of baseLocales) {
mergedLocales.set(locale.code, locale)
}
Expand All @@ -516,9 +518,7 @@ export const mergeConfigLocales = (configs: LocaleConfig[], baseLocales: LocaleO
delete locale.file

if (locale.iso) {
console.warn(
`Locale ${locale.iso} uses deprecated \`iso\` property, this will be replaced with \`language\` in v9`
)
deprecatedIsolocales.add(locale.iso)
locale.language = locale.iso
delete locale.iso
}
Expand All @@ -539,6 +539,12 @@ export const mergeConfigLocales = (configs: LocaleConfig[], baseLocales: LocaleO
}
}

if (deprecatedIsolocales.size) {
console.warn(
`Locales ${[...deprecatedIsolocales].join(', ')} uses deprecated \`iso\` property, this will be replaced with \`language\` in v9`
)
}

return Array.from(mergedLocales.values())
}

Expand Down

0 comments on commit 571a510

Please sign in to comment.