Skip to content

Commit

Permalink
Add a code-quality check for translations (#6358)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Aug 6, 2024
1 parent 99d96a2 commit bad266b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,26 @@ jobs:
# TODO(#6272): Incorporate more checks from CRAN_Release
}
shell: Rscript {0}
lint-po:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
- name: Check translations
run: |
setwd("po")
for (po_file in list.files(pattern = "[.]po$")) {
res = tools::checkPoFile(po_file, strictPlural=TRUE)
if (NROW(res)) { print(res); stop("Fix the above .po file issues.") }
if (!any(grepl("charset=UTF-8", readLines(po_file), fixed=TRUE)))
stop("In ", po_file, ", please use charset=UTF-8.")
res = system2("msgfmt", c("--statistics", po_file, "-o", tempfile()), stdout=TRUE, stderr=TRUE)
if (any(grepl("untranslated message|fuzzy translation", res))) {
cat(sprintf("In %s, found incomplete translations:\n%s\n", po_file, paste(res, collapse="\n")))
stop("Please fix.")
}
}
cat("All translation quality checks completed successfully!\n")
shell: Rscript {0}

0 comments on commit bad266b

Please sign in to comment.