Skip to content

Commit

Permalink
chore: add workflow to check locale files in pull requests (mainsail-…
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored and dw-0 committed Jul 3, 2022
1 parent 99e45fd commit fe691d1
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 87 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/check_locale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Check Translations
on:
pull_request_target:
types: [synchronize, opened]
paths:
- 'src/locales/**'

jobs:
check_translations:
runs-on: ubuntu-latest
steps:
- name: Install jq
run: sudo apt install -y jq

- name: Fetch repo
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Install node
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install dependencies
run: npm ci

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v23
with:
sha: ${{ github.event.pull_request.head.sha }}
files: 'src/locales/*.json'

- name: Run i18n-extract on changed locale files
id: i18n-extract
env:
OUTPUT: ''
run: |
mkdir ./i18n-extract
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
npm run i18n-extract -- --languageFiles=src/locales/${file##*/} --output=i18n-extract/${file##*/}
MISSING=$(cat i18n-extract/${file##*/} | jq '.missingKeys | length')
UNUSED=$(cat i18n-extract/${file##*/} | jq '.unusedKeys | length')
echo "::set-output name=$file::|${file##*/}|${MISSING}|${UNUSED}|"
done
- name: Comment PR
uses: thollander/actions-comment-pull-request@v1
with:
message: |
Language file analysis report:
|File|Missing Keys|Unused Keys|
|:---|---:|---:|
${{join(steps.i18n-extract.outputs.*, '
')}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157 changes: 78 additions & 79 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"vite-plugin-pwa": "^0.11.13",
"vite-plugin-vue2": "^1.9.3",
"vue-debounce-decorator": "^1.0.1",
"vue-i18n-extract": "^1.2.3",
"vue-i18n-extract": "^2.0.7",
"vue-router": "^3.5.2",
"vue-template-compiler": "^2.6.14",
"workbox-core": "^6.4.2"
Expand Down
13 changes: 6 additions & 7 deletions vue-i18n-extract.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
module.exports = {
vueFilesPath: './src/**/{*.?(js|ts|vue),.i18nignore}',
languageFilesPath: './src/locales/*.json',
options: {
output: false,
add: false,
dynamic: true,
},
vueFiles: './src/**/{*.?(js|ts|vue),.i18nignore}',
languageFiles: './src/locales/*.json',
exclude: ['_last_update'],
output: false,
add: false,
ci: false,
}

0 comments on commit fe691d1

Please sign in to comment.