mirror of
https://github.com/zen-browser/desktop.git
synced 2025-12-22 14:19:05 +00:00
feat: Apply a language code map for certain locales, p=#11669, c=scripts
This commit is contained in:
1
locales/language-maps
Normal file
1
locales/language-maps
Normal file
@@ -0,0 +1 @@
|
||||
nb:nb-NO
|
||||
@@ -21,7 +21,7 @@
|
||||
"sync:raw": "surfer update",
|
||||
"sync:rc": "python3 scripts/update_ff.py --rc",
|
||||
"sync:l10n": "python3 scripts/update_ff.py --just-l10n",
|
||||
"pretty": "prettier . --write --cache && autopep8 -r --in-place scripts/ src/",
|
||||
"pretty": "prettier . --write --cache && autopep8 -r --in-place scripts/ src/ --exclude */tests/*",
|
||||
"lint": "npx eslint src/ && prettier . --check --cache",
|
||||
"lint:fix": "npm run pretty && npx eslint src/ --fix",
|
||||
"prepare": "husky",
|
||||
|
||||
@@ -10,13 +10,32 @@ import sys
|
||||
BROWSER_LOCALES = "engine/browser/locales"
|
||||
|
||||
|
||||
def get_language_code(lang_id: str) -> str:
|
||||
"""
|
||||
Retrieves the language code from the language-maps file.
|
||||
|
||||
:param lang_id: Language identifier (e.g., 'nb', 'fr', etc.)
|
||||
:return: Corresponding language code (e.g., 'nb-NO', 'fr-FR', etc.)
|
||||
"""
|
||||
language_maps_path = os.path.join("locales", "language-maps")
|
||||
if not os.path.exists(language_maps_path):
|
||||
return lang_id # Return the original if the file doesn't exist
|
||||
|
||||
with open(language_maps_path, "r", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
if line.startswith(f"{lang_id}:"):
|
||||
return line.split(":", 1)[1].strip()
|
||||
return lang_id # Return the original if no mapping is found
|
||||
|
||||
|
||||
def copy_browser_locales(lang_id: str):
|
||||
"""
|
||||
Copies language pack files to the specified browser locale directory.
|
||||
|
||||
:param lang_id: Language identifier (e.g., 'en-US', 'fr', etc.)
|
||||
"""
|
||||
lang_path = os.path.join(BROWSER_LOCALES, lang_id)
|
||||
lang_code = get_language_code(lang_id)
|
||||
lang_path = os.path.join(BROWSER_LOCALES, lang_code)
|
||||
|
||||
# Create the directory for the language pack if it doesn't exist
|
||||
os.makedirs(lang_path, exist_ok=True)
|
||||
|
||||
@@ -39,10 +39,20 @@ fi
|
||||
|
||||
set -e
|
||||
|
||||
update_language() {
|
||||
get_code_for_language() {
|
||||
# Get the language code from locales/language-maps
|
||||
langId=$1
|
||||
code=$(grep "^$langId:" ./locales/language-maps | cut -d':' -f2)
|
||||
if [ -z "$code" ]; then
|
||||
code=$langId
|
||||
fi
|
||||
echo $code
|
||||
}
|
||||
|
||||
update_language() {
|
||||
langId=$(get_code_for_language $1)
|
||||
cd ./locales
|
||||
cd $langId
|
||||
cd $1
|
||||
|
||||
echo "Updating $langId"
|
||||
# move the contents from ../firefox-l10n/$langId to ./locales/$langId
|
||||
|
||||
Reference in New Issue
Block a user