Skip to content

Commit bad266b

Browse files
Add a code-quality check for translations (#6358)
1 parent 99d96a2 commit bad266b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.github/workflows/code-quality.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,26 @@ jobs:
4747
# TODO(#6272): Incorporate more checks from CRAN_Release
4848
}
4949
shell: Rscript {0}
50+
lint-po:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
- uses: r-lib/actions/setup-r@v2
55+
- name: Check translations
56+
run: |
57+
setwd("po")
58+
for (po_file in list.files(pattern = "[.]po$")) {
59+
res = tools::checkPoFile(po_file, strictPlural=TRUE)
60+
if (NROW(res)) { print(res); stop("Fix the above .po file issues.") }
61+
62+
if (!any(grepl("charset=UTF-8", readLines(po_file), fixed=TRUE)))
63+
stop("In ", po_file, ", please use charset=UTF-8.")
64+
65+
res = system2("msgfmt", c("--statistics", po_file, "-o", tempfile()), stdout=TRUE, stderr=TRUE)
66+
if (any(grepl("untranslated message|fuzzy translation", res))) {
67+
cat(sprintf("In %s, found incomplete translations:\n%s\n", po_file, paste(res, collapse="\n")))
68+
stop("Please fix.")
69+
}
70+
}
71+
cat("All translation quality checks completed successfully!\n")
72+
shell: Rscript {0}

0 commit comments

Comments
 (0)