Skip to content

Commit 52628ce

Browse files
committed
bump version to 1.12.1 in package.json; enhance getLocales function to include locale mappings
1 parent 0d61d25 commit 52628ce

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zen-browser/surfer",
3-
"version": "1.12.0",
3+
"version": "1.12.1",
44
"description": "Simplifying building firefox forks!",
55
"main": "index.js",
66
"bin": {

src/commands/package.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,23 @@ const machPath = resolve(ENGINE_DIR, 'mach')
2222
async function getLocales() {
2323
// locales/supported-languages is a list of locales divided by newlines
2424
// open the file and split it by newlines
25-
const localesText = await readFile('locales/supported-languages', 'utf-8')
25+
let localesText = await readFile('locales/supported-languages', 'utf-8');
26+
const languageMaps = await readFile('locales/language-maps', 'utf-8');
27+
// Language maps contains a list of locale mappings for specific locales
28+
// e.g. "nb:nb-NO" means that "nb" should be mapped to "nb-NO"
29+
const mappings: Record<string, string> = {}
30+
for (const line of languageMaps.split('\n')) {
31+
const [key, value] = line.split(':')
32+
if (key && value) {
33+
mappings[key.trim()] = value.trim()
34+
}
35+
}
36+
localesText = localesText
37+
.split('\n')
38+
.map((locale) => locale.trim())
39+
.filter((locale) => locale.length > 0)
40+
.map((locale) => (mappings[locale] ? mappings[locale] : locale))
41+
.join('\n')
2642
log.info(`Found locales:\n${localesText}`)
2743
return localesText.split('\n')
2844
}

0 commit comments

Comments
 (0)