Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
96 changes: 47 additions & 49 deletions .github/scripts/langCodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,57 @@

# Mapping between Crowdin language IDs (keys) and standard NVDA directory names (values).
# This dictionary acts as the symmetrical counterpart to 'languageMappings.json' implemented by @nvdaes.
# It ensures that translations exported from Crowdin are stored in the correct
# It ensures that translations exported from Crowdin are stored in the correct
# local paths (e.g., 'es-ES' from Crowdin goes into the 'es' folder).
CROWDIN_TO_NVDA = {
# Arabic variants
"ar-SA": "ar_SA",

# Spanish variants
"es-ES": "es",
"es-CO": "es_CO",

# Portuguese variants
"pt-BR": "pt_BR",
"pt-PT": "pt_PT",

# Chinese variants
"zh-CN": "zh_CN",
"zh-HK": "zh_HK",
"zh-TW": "zh_TW",

# Other specific mappings from the NVDA ecosystem
"af": "af_ZA",
"de-CH": "de_CH",
"nb": "nb_NO",
"nn-NO": "nn_NO",
"sr-CS": "sr"
# Arabic variants
"ar-SA": "ar_SA",
# Spanish variants
"es-ES": "es",
"es-CO": "es_CO",
# Portuguese variants
"pt-BR": "pt_BR",
"pt-PT": "pt_PT",
# Chinese variants
"zh-CN": "zh_CN",
"zh-HK": "zh_HK",
"zh-TW": "zh_TW",
# Other specific mappings from the NVDA ecosystem
"af": "af_ZA",
"de-CH": "de_CH",
"nb": "nb_NO",
"nn-NO": "nn_NO",
"sr-CS": "sr",
}


def get_nvda_code(crowdin_code):
"""
Returns the appropriate local directory name for a given Crowdin language ID.

Args:
crowdin_code (str): The language identifier from Crowdin (e.g., 'pt-BR', 'fr').

Returns:
str: The corresponding NVDA locale folder name (e.g., 'pt_BR', 'fr').
"""
# 1. Direct check in our verified map (Priority)
if crowdin_code in CROWDIN_TO_NVDA:
return CROWDIN_TO_NVDA[crowdin_code]

# 2. Automated conversion for regional variants: Crowdin "xx-YY" -> NVDA "xx_YY"
# This handles regional codes not explicitly defined in the map.
if "-" in crowdin_code:
return crowdin_code.replace("-", "_")

# 3. Default: Return as is.
# This covers base languages that don't use regional folders in NVDA
# (e.g., 'fr', 'tr', 'bg', 'fi', 'fa').
return crowdin_code
"""
Returns the appropriate local directory name for a given Crowdin language ID.

Args:
crowdin_code (str): The language identifier from Crowdin (e.g., 'pt-BR', 'fr').

Returns:
str: The corresponding NVDA locale folder name (e.g., 'pt_BR', 'fr').
"""
# 1. Direct check in our verified map (Priority)
if crowdin_code in CROWDIN_TO_NVDA:
return CROWDIN_TO_NVDA[crowdin_code]

# 2. Automated conversion for regional variants: Crowdin "xx-YY" -> NVDA "xx_YY"
# This handles regional codes not explicitly defined in the map.
if "-" in crowdin_code:
return crowdin_code.replace("-", "_")

# 3. Default: Return as is.
# This covers base languages that don't use regional folders in NVDA
# (e.g., 'fr', 'tr', 'bg', 'fi', 'fa').
return crowdin_code


if __name__ == "__main__":
# Ensure a language code was provided as a command-line argument
if len(sys.argv) > 1:
# Standardize input and output the mapped code for PowerShell to capture
print(get_nvda_code(sys.argv[1]))
# Ensure a language code was provided as a command-line argument
if len(sys.argv) > 1:
# Standardize input and output the mapped code for PowerShell to capture
print(get_nvda_code(sys.argv[1]))
1 change: 0 additions & 1 deletion .github/workflows/auto-update-translations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ on:
jobs:
auto_update_translations:
uses: abdel792/autoUpdateTranslations/.github/workflows/l10n-updates.yaml@8ac89c644395cf2aad6e03a4bb2be5c36526d12a

2 changes: 1 addition & 1 deletion .github/workflows/manual-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
f.seek(0)
f.write(text)
f.truncate()
shell: python
shell: python


- name: Check if there are any changes
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
- id: check-hooks-apply

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
# Prevents commits to certain branches
- id: no-commit-to-branch
Expand Down Expand Up @@ -60,7 +60,7 @@ repos:
# Avoids using reserved Windows filenames.
- id: check-illegal-windows-names
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.2.0
rev: v4.0.0
hooks:
# Ruff preserves indent/new-line formatting of function arguments, list items, and similar iterables,
# if a trailing comma is added.
Expand All @@ -69,7 +69,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Matches Ruff version in pyproject.
rev: v0.12.7
rev: v0.15.12
hooks:
- id: ruff
name: lint with ruff
Expand Down
Loading
Loading