forked from mainsail-crew/mainsail
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add workflow to check locale files in pull requests (mainsail-…
- Loading branch information
Showing
4 changed files
with
142 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |