feat(locale): provide code (#2611)

This commit is contained in:
Alex
2024-11-12 16:57:40 +05:00
committed by GitHub
parent 30218f1b5b
commit 8a8b1ee2e1
16 changed files with 45 additions and 14 deletions

View File

@@ -15,3 +15,17 @@ export async function appendFile(path, contents) {
await fsp.writeFile(path, file.trim() + '\n' + contents + '\n')
}
}
export function normalizeLocale(locale) {
if (!locale) {
return ''
}
if (locale.includes('_')) {
return locale.split('_')
.map((part, index) => index === 0 ? part.toLowerCase() : part.toUpperCase())
.join('-')
}
return locale.toLowerCase()
}