GitHub Action
i18n coverage
Github action that can be used to measure how many of you translatable strings have a translation available. Currently supported formats:
The action can also attach a neutral/success/failure check to the head commit that triggered the workflow, with the coverage results for each found language.
Note, that you must include a checkout step before using this action in order to have the translations available. (Or any other alternative method ot get the translation files)
on: [push]
jobs:
i18n-coverage:
runs-on: ubuntu-latest
name: Check i18n coverage
steps:
- uses: actions/checkout@v2
- name: Check i18n coverage
uses: alexkiro/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
translations-path: 'translations/**/*.po'
ignore-languages: 'en'
The total coverage percentage can also be retrieved from the output. E.g:
on: [push]
jobs:
i18n-coverage:
runs-on: ubuntu-latest
name: Check i18n coverage
steps:
- uses: actions/checkout@v2
- name: Check i18n coverage
id: i18nCoverage
uses: alexkiro/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
translations-path: 'translations/**/*.po'
ignore-languages: 'en'
- name: Get the coverage
run: echo "The coverage was ${{ steps.i18nCoverage.outputs.coverage }}"
The check details will be added to the triggered commit and will be displayed in GitHub. E.g:
Including the full details. E.g:
The glob patterns to the translations files to check. Defaults to "translations/**/*.po".
Github secret token, usually set to ${{ secrets.GITHUB_TOKEN }}
. If not specified the check details
are not attached to the commit, and therefore can only be found and used in the action workflow.
The minimum coverage required for this check to be marked as success. If not set or set to 0 the check is marked as neutral. Float values are supported.
Comma separated list of languages codes; if specified these languages will be excluded from the check.
Comma separated list of languages codes; if specified only these languages will be checked instead of all.
Total percentage of translated strings, across all checked languages.
Steps to prepare dev environment:
- Ensure you have nodejs version 12+ installed
- Clone the repository
- Install dependencies:
npm install
- (Optional) Compile messages:
./compilemessages.sh
The main code entrypoint is src/index.js
This action is using @zeit/ncc to deploy the the index.js together with required dependencies. A new build can be created using:
npm run build
This will update the dist/index.js file, which then needs to be committed and pushed to the repo. If this step is
The repo uses ESLint for linting. To lint and fix the code you can run:
npm run lint
There are no automated tests, however the github workflow will currently run the latest version of the
action on the translations
folder in the repo. This functions as a very basic smoke test.
The translations are managed using the sample code and the two scripts:
- makemesssages.sh (updates po files)
- compilemessages.sh (compiles po files into mo)