@@ -23,15 +23,17 @@ if (Test-Path $mdFile) {
2323 try {
2424 Copy-Item " $addonId .xliff" $tempXliff - Force
2525 Write-Host " DEBUG: Updating XLIFF source based on readme.md..."
26- uv run .github/ scripts/ markdownTranslate.py updateXliff - m $mdFile - x $tempXliff - o $xliffFile
27- } finally {
26+ ./ l10nUtil.exe md2xliff $mdFile $xliffFile - o $tempXliff
27+ }
28+ finally {
2829 if (Test-Path $tempXliff ) {
2930 Remove-Item $tempXliff - Force
3031 }
3132 }
32- } else {
33+ }
34+ else {
3335 Write-Host " DEBUG: XLIFF template not found. Creating new one from readme.md..."
34- uv run .github / scripts / markdownTranslate.py generateXliff - m $mdFile - o $xliffFile
36+ . / l10nUtil.exe md2xliff $mdFile $xliffFile
3537 }
3638}
3739
@@ -49,8 +51,10 @@ if (Test-Path $potFile) {
4951if (Test-Path $xliffFile ) {
5052 Write-Host " DEBUG: Uploading updated XLIFF source to Crowdin..."
5153 ./ l10nUtil.exe uploadSourceFile " $xliffFile " - c $env: L10N_UTIL_CONFIG
54+
5255 git add " $xliffFile "
5356 git diff -- staged -- quiet
57+
5458 if ($LASTEXITCODE -ne 0 ) {
5559 git commit - m " Update $xliffFile for $addonId "
5660 }
@@ -69,127 +73,155 @@ New-Item -ItemType Directory -Force -Path addon/doc | Out-Null
6973$languageMappings = Get-Content - Raw " .github/scripts/languageMappings.json" | ConvertFrom-Json
7074
7175foreach ($dir in Get-ChildItem - Path " _addonL10n/$addonId " - Directory) {
76+
7277 $langCode = $dir.Name
7378
74- if ($langCode -eq " en" ) { continue }
79+ if ($langCode -eq " en" ) {
80+ continue
81+ }
7582
7683 # --- Identify codes
84+
7785 $crowdinLang = $null
7886
79- # Use the ."variable" syntax to correctly read the PSCustomObject from JSON
8087 if ($languageMappings.PSObject.Properties.Name -contains $langCode ) {
8188 $crowdinLang = $languageMappings ." $langCode "
8289 }
8390
84- # Fallback: If no mapping is found, replace underscores with dashes for Crowdin compatibility
8591 if (-not $crowdinLang ) {
8692 $crowdinLang = $langCode.Replace (' _' , ' -' )
8793 }
8894
89- # The $langCode (folder name from Crowdin) represents the local repository language code.
90- # It matches the NVDA directory structure, so no extra mapping is needed.
9195 Write-Host " --- Processing Language: $langCode (Crowdin: $crowdinLang ) ---" - ForegroundColor Cyan
9296
9397 # Paths
94- $remoteMd = Join-Path $dir .FullName " $addonId .md "
98+
9599 $remoteXliff = Join-Path $dir.FullName " $addonId .xliff"
96100 $remotePo = Join-Path $dir.FullName " $addonId .po"
101+
97102 $localMdDir = " addon/doc/$langCode "
98103 $localMd = " $localMdDir /readme.md"
104+
99105 $localPoPath = " addon/locale/$langCode /LC_MESSAGES/nvda.po"
100106
101107 # --- 3.1 PO FILE PROCESSING ---
102108 $poImported = $false
109+ $scorePo = 0.0
110+ $threshold = $env: MIN_PERCENTAGE_TRANSLATED
111+
103112 if (Test-Path $remotePo ) {
104- Write-Host " DEBUG: Checking Remote PO progress for $crowdinLang ..."
105- uv run python .github/ scripts/ checkTranslation.py " $addonId .po" $crowdinLang
106- if ($LASTEXITCODE -eq 0 ) {
107- Write-Host " SUCCESS: Remote PO is valid. Importing to $localPoPath "
113+
114+ Write-Host " DEBUG: Evaluating Remote PO score..."
115+
116+ $res = uv run python .github/ scripts/ checkTranslation.py " $addonId .po" $crowdinLang
117+
118+ $scorePo = [double ](
119+ ($res | Select-String " poScore=" ).ToString().Split(" =" )[1 ]
120+ )
121+
122+ Write-Host " DEBUG: PO Score -> $scorePo "
123+
124+ if ($scorePo -ge $threshold ) {
125+
126+ Write-Host " SUCCESS: Remote PO is above threshold. Importing to $localPoPath "
127+
108128 New-Item - ItemType Directory - Force - Path (Split-Path $localPoPath ) | Out-Null
129+
109130 Move-Item $remotePo $localPoPath - Force
131+
110132 $poImported = $true
111- } else {
112- Write-Host " WARNING: Remote PO progress is below threshold."
133+ }
134+ else {
135+
136+ Write-Host " WARNING: Remote PO score is below threshold ($threshold )."
113137 }
114138 }
115139
116140 if (-not $poImported -and (Test-Path $localPoPath )) {
141+
117142 Write-Host " ACTION: Uploading local legacy PO to Crowdin ($crowdinLang ) as fallback."
143+
118144 ./ l10nUtil.exe uploadTranslationFile $crowdinLang " $addonId .po" $localPoPath - c $env: L10N_UTIL_CONFIG
119145 }
120146
121- # --- 3.2 DOCUMENTATION PROCESSING (MD & XLIFF) ---
122- $scoreMd = 0.0
123- $scoreXliff = 0.0
147+ # --- 3.2 DOCUMENTATION PROCESSING (XLIFF ONLY) ---
124148
125- if (Test-Path $remoteMd ) {
126- Write-Host " DEBUG: Evaluating Remote Markdown score..."
127- $res = uv run python .github/ scripts/ checkTranslation.py " $addonId .md" $crowdinLang
128- $scoreMd = [double ]($res | Select-String " mdScore=" ).ToString().Split(" =" )[1 ]
129- } else {
130- Write-Host " DEBUG: No remote Markdown file found for this language."
131- }
149+ $scoreXliff = 0.0
132150
133151 if (Test-Path $remoteXliff ) {
152+
134153 Write-Host " DEBUG: Evaluating Remote XLIFF score..."
154+
135155 $res = uv run python .github/ scripts/ checkTranslation.py " $addonId .xliff" $crowdinLang
136- $scoreXliff = [double ]($res | Select-String " xliffScore=" ).ToString().Split(" =" )[1 ]
137- } else {
156+
157+ $scoreXliff = [double ](
158+ ($res | Select-String " xliffScore=" ).ToString().Split(" =" )[1 ]
159+ )
160+ }
161+ else {
138162 Write-Host " DEBUG: No remote XLIFF file found for this language."
139163 }
140164
141- Write-Host " DEBUG: Comparison Scores -> MD: $scoreMd | XLIFF: $scoreXliff "
165+ Write-Host " DEBUG: XLIFF Score -> $scoreXliff "
142166
143- $threshold = 0.5
167+ $threshold = $ env: MIN_PERCENTAGE_TRANSLATED
144168 $docImported = $false
145169
146- if ($scoreXliff -gt $threshold -or $scoreMd -gt $threshold ) {
147- if (! (Test-Path $localMdDir )) { New-Item - ItemType Directory - Force - Path $localMdDir | Out-Null }
148-
149- if ($scoreXliff -ge $scoreMd ) {
150- Write-Host " SUCCESS: XLIFF is better or equal. Converting XLIFF to local MD ($langCode )..."
151- ./ l10nUtil.exe xliff2md $remoteXliff $localMd
152- $docImported = $true
153- } else {
154- Write-Host " SUCCESS: Markdown is better. Importing Remote MD to local ($langCode )..."
155- Move-Item $remoteMd $localMd - Force
156- $docImported = $true
170+ if ($scoreXliff -ge $threshold ) {
171+
172+ if (! (Test-Path $localMdDir )) {
173+ New-Item - ItemType Directory - Force - Path $localMdDir | Out-Null
157174 }
158- } else {
159- Write-Host " WARNING: Both remote MD and XLIFF scores are below threshold ($threshold )."
175+
176+ Write-Host " SUCCESS: Importing documentation from XLIFF ($langCode )..."
177+
178+ ./ l10nUtil.exe xliff2md $remoteXliff $localMd
179+
180+ $docImported = $true
160181 }
182+ else {
161183
162- if (-not $docImported -and (Test-Path $localMd )) {
163- Write-Host " ACTION: Documentation quality too low. Uploading local MD to Crowdin ($crowdinLang ) as fallback."
164- ./ l10nUtil.exe uploadTranslationFile $crowdinLang " $addonId .md" $localMd - c $env: L10N_UTIL_CONFIG
184+ Write-Host " WARNING: Remote XLIFF score is below threshold ($threshold )."
165185 }
186+
187+ # No Markdown fallback upload anymore.
188+ # XLIFF is now the single translation source in Crowdin.
166189}
167190
168191# --- STEP 4: COMMIT UPDATED TRANSLATIONS ---
169192
170193git add addon/ locale addon/ doc
194+
171195git diff -- staged -- quiet
196+
172197if ($LASTEXITCODE -ne 0 ) {
198+
173199 git commit - m " Update translations for $addonId from Crowdin (Automatic Sync)"
200+
174201 Write-Host " SUCCESS: Translations committed."
175- } else {
202+ }
203+ else {
204+
176205 Write-Host " DEBUG: No changes in translations to commit."
177206}
178207
179208# Push all generated commits after successful Crowdin synchronization
209+
180210$pushOutput = git push 2>&1
181211
182- # Get the full repository name in "owner/repository" format (e.g., hkatic/clock)
183212$repository = $env: GITHUB_REPOSITORY
184213
185214Write-Host $pushOutput
186215
187216if ($LASTEXITCODE -ne 0 ) {
217+
188218 Write-Host " ERROR: Failed to push commits to $repository ."
189219}
190220elseif ($pushOutput -match " Everything up-to-date" ) {
221+
191222 Write-Host " INFO: No new commits needed to be pushed."
192223}
193224else {
225+
194226 Write-Host " SUCCESS: New commits successfully pushed to $repository ."
195227}
0 commit comments