Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a code-quality check for translations #6358

Merged
merged 2 commits into from
Aug 6, 2024
Merged
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
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}
Loading