7070 tar -xzf "$RUNNER_TEMP/txcli/tx.tar.gz" -C "$RUNNER_TEMP/txcli"
7171
7272 TX_BINARY="$(find "$RUNNER_TEMP/txcli" -type f -name tx -print -quit)"
73+
7374 if [ -z "$TX_BINARY" ]; then
7475 echo "ERROR: Transifex CLI binary was not found in the archive."
7576 find "$RUNNER_TEMP/txcli" -maxdepth 3 -type f -print
9899 from pathlib import Path
99100
100101 path = Path(".tx/config")
101- config = configparser.ConfigParser()
102+ config = configparser.ConfigParser(interpolation=None )
102103
103104 if not path.is_file() or not config.read(path):
104105 raise SystemExit("ERROR: .tx/config was not generated")
@@ -120,6 +121,7 @@ jobs:
120121 }
121122
122123 missing = expected - resources.keys()
124+
123125 if missing:
124126 raise SystemExit(
125127 "ERROR: missing builtins resources: "
@@ -128,15 +130,23 @@ jobs:
128130
129131 for resource in sorted(expected):
130132 section = resources[resource]
131- source = config.get(section, "source_file", fallback="").strip()
132- expected_source = f"gettext/{resource.replace('--', '/')}.pot"
133+ source = config.get(
134+ section, "source_file", fallback=""
135+ ).strip()
136+
137+ expected_source = (
138+ f"gettext/{resource.replace('--', '/')}.pot"
139+ )
133140
134141 if source != expected_source:
135142 raise SystemExit(
136- f"ERROR: unexpected source_file for {resource}: {source}"
143+ f"ERROR: unexpected source_file for {resource}: "
144+ f"{source}"
137145 )
138146
139- print("Transifex configuration and all seven builtins mappings validated.")
147+ print(
148+ "Transifex configuration and all seven builtins mappings validated."
149+ )
140150 PY
141151
142152 - name : Diagnose builtins index resource
@@ -146,22 +156,37 @@ jobs:
146156 import configparser
147157 from pathlib import Path
148158
149- config = configparser.ConfigParser()
150- config.read(".tx/config")
159+ config = configparser.ConfigParser(interpolation=None)
160+
161+ if not config.read(".tx/config"):
162+ raise SystemExit("ERROR: Could not read .tx/config")
151163
152164 section = "o:python-doc:p:python-newest:r:builtins--index"
153165
154166 if not config.has_section(section):
155- raise SystemExit(f"ERROR: missing Transifex resource: {section}")
167+ raise SystemExit(
168+ f"ERROR: missing Transifex resource: {section}"
169+ )
156170
157171 print("=== Generated Transifex mapping ===")
158- for key in ("file_filter", "source_file", "type", "resource_name"):
159- print(f"{key} = {config.get(section, key, fallback='<missing>')}")
172+
173+ for key in (
174+ "file_filter",
175+ "source_file",
176+ "type",
177+ "resource_name",
178+ ):
179+ print(
180+ f"{key} = "
181+ f"{config.get(section, key, fallback='<missing>')}"
182+ )
160183
161184 po_path = Path("builtins/index.po")
162185
163186 if not po_path.is_file():
164- raise SystemExit(f"ERROR: translation file not found: {po_path}")
187+ raise SystemExit(
188+ f"ERROR: translation file not found: {po_path}"
189+ )
165190
166191 print(f"\nTranslation file exists: {po_path}")
167192
@@ -170,10 +195,13 @@ jobs:
170195 msgstr = ""
171196 field = None
172197
173- for line in po_path.read_text(encoding="utf-8").splitlines() + [""]:
198+ for line in (
199+ po_path.read_text(encoding="utf-8").splitlines() + [""]
200+ ):
174201 if line.startswith("msgid "):
175202 if msgid is not None:
176203 entries.append((msgid, msgstr))
204+
177205 msgid = ast.literal_eval(line[6:])
178206 msgstr = ""
179207 field = "msgid"
@@ -184,6 +212,7 @@ jobs:
184212
185213 elif line.startswith('"') and field:
186214 value = ast.literal_eval(line)
215+
187216 if field == "msgid":
188217 msgid += value
189218 else:
@@ -192,6 +221,7 @@ jobs:
192221 elif not line.strip():
193222 if msgid is not None:
194223 entries.append((msgid, msgstr))
224+
195225 msgid = None
196226 msgstr = ""
197227 field = None
@@ -205,16 +235,76 @@ jobs:
205235 print(f"Non-empty translated entries: {len(translated)}")
206236
207237 for source, target in translated:
208- print(f" {source[:100]!r} -> {target[:100]!r}")
238+ print(
239+ f" {source[:100]!r} -> {target[:100]!r}"
240+ )
209241
210242 if len(translated) < 5:
211243 raise SystemExit(
212- "ERROR: expected at least five translated entries in builtins/index.po"
244+ "ERROR: expected at least five translated entries "
245+ "in builtins/index.po"
213246 )
214247
215248 print("Builtins index diagnostic passed.")
216249 PY
217250
251+ - name : Stage builtins index translation for Transifex
252+ run : |
253+ python - <<'PY'
254+ import configparser
255+ import shutil
256+ from pathlib import Path
257+
258+ config_path = Path(".tx/config")
259+ config = configparser.ConfigParser(interpolation=None)
260+
261+ if not config.read(config_path):
262+ raise SystemExit("ERROR: Could not read .tx/config")
263+
264+ section = "o:python-doc:p:python-newest:r:builtins--index"
265+
266+ if not config.has_section(section):
267+ raise SystemExit(
268+ f"ERROR: Missing Transifex resource: {section}"
269+ )
270+
271+ source = Path("builtins/index.po")
272+ staged = Path("builtins/pa/index.po")
273+
274+ if not source.is_file():
275+ raise SystemExit(
276+ f"ERROR: Missing translation file: {source}"
277+ )
278+
279+ staged.parent.mkdir(parents=True, exist_ok=True)
280+ shutil.copy2(source, staged)
281+
282+ config.set(
283+ section,
284+ "file_filter",
285+ "builtins/<lang>/index.po",
286+ )
287+
288+ with config_path.open("w", encoding="utf-8") as file:
289+ config.write(file)
290+
291+ print(f"Staged Punjabi translation: {staged}")
292+ print(
293+ "Updated file_filter:",
294+ config.get(section, "file_filter"),
295+ )
296+
297+ if not staged.is_file():
298+ raise SystemExit("ERROR: Staged translation was not created")
299+
300+ if staged.read_bytes() != source.read_bytes():
301+ raise SystemExit(
302+ "ERROR: Staged translation differs from the original"
303+ )
304+
305+ print("Staged translation validated successfully.")
306+ PY
307+
218308 - name : Push Punjabi translations
219309 env :
220310 TX_TOKEN : ${{ secrets.TX_TOKEN }}
@@ -224,14 +314,12 @@ jobs:
224314 --languages "$TX_LANGUAGE" \
225315 --use-git-timestamps
226316
227- - name : Verify Transifex index resource status
317+ - name : Report Transifex push status
228318 if : always()
229- env :
230- TX_TOKEN : ${{ secrets.TX_TOKEN }}
231319 run : |
232- echo "The push command has finished ."
233- echo "Inspect the preceding Transifex CLI logs for builtins--index."
234- echo "This step does not independently verify remote translation contents ."
320+ echo "Review the preceding Transifex CLI logs ."
321+ echo "Confirm that builtins--index was processed successfully ."
322+ echo "A successful command alone does not prove that remote translations changed ."
235323
236324 push-sources :
237325 name : Generate and push source templates
@@ -279,6 +367,7 @@ jobs:
279367 tar -xzf "$RUNNER_TEMP/txcli/tx.tar.gz" -C "$RUNNER_TEMP/txcli"
280368
281369 TX_BINARY="$(find "$RUNNER_TEMP/txcli" -type f -name tx -print -quit)"
370+
282371 if [ -z "$TX_BINARY" ]; then
283372 echo "ERROR: Transifex CLI binary was not found in the archive."
284373 find "$RUNNER_TEMP/txcli" -maxdepth 3 -type f -print
@@ -314,15 +403,18 @@ jobs:
314403 from pathlib import Path
315404
316405 path = Path(".tx/config")
317- config = configparser.ConfigParser()
406+ config = configparser.ConfigParser(interpolation=None )
318407
319408 if not path.is_file() or not config.read(path):
320409 raise SystemExit("ERROR: .tx/config was not generated")
321410
322411 missing = []
323412
324413 for section in config.sections():
325- source = config.get(section, "source_file", fallback="").strip()
414+ source = config.get(
415+ section, "source_file", fallback=""
416+ ).strip()
417+
326418 if source and not Path(source).is_file():
327419 missing.append(f"{section}: {source}")
328420
@@ -338,4 +430,4 @@ jobs:
338430 env :
339431 TX_TOKEN : ${{ secrets.TX_TOKEN }}
340432 run : |
341- /usr/local/bin/tx push --source --skip
433+ /usr/local/bin/tx push --source --skip
0 commit comments