Skip to content

Commit

Permalink
chore: set up i18n automation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kohei Asai committed Feb 18, 2024
1 parent 8b3314d commit a4c4f3f
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Code Format Check
name: Check
on:
- pull_request
jobs:
Expand All @@ -12,7 +12,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 21
- name: Install Dependencies
- name: Install dependencies
run: npm ci
- name: Run Prettier Check
run: npx prettier --check .
Expand All @@ -26,7 +26,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 21
- name: Install Dependencies
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npx eslint .
39 changes: 39 additions & 0 deletions .github/workflows/i18n-download.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: I18n Dictionary Download
on:
repository_dispatch:
types:
- simplelocalize_publication
jobs:
download-and-apply:
name: Dictionary Download
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install SimpleLocalize CLI
run: curl -s https://get.simplelocalize.io/2.5/install | bash
- name: Download the dictionary files from artifacts
uses: actions/download-artifact@v4
with:
name: i18n-dictionaries
path: ${{ runner.temp }}/i18next
- name: Upload the dictionary files to SimpleLocalize
run: |
simplelocalize download \
--apiKey ${{ secrets.SIMPLELOCALIZE_API_KEY }} \
--downloadFormat=single-language-json \
--downloadPath=./src/locales/{lang}/{ns}.json
- name: Upload the parsed dictionary files as artifacts
run: |
git switch -c i18n-update-${{ github.run_id }}
git add .
git commit -m "feat(i18n): apply i18n dictionary update(s)"
git push origin i18n-update-${{ github.run_id }}
- name: Create a pull request
run: |
gh pr create \
--base main \
--head i18n-update-${{ github.run_id }} \
--assignee @me \
--title "feat(i18n): apply i18n dictionary update(s)"
--reviewer @axross
31 changes: 31 additions & 0 deletions .github/workflows/i18n-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: I18n Dictionary Upload
on:
push:
branches:
- main
- i18n-automation-setup
jobs:
parse-and-upload:
name: Dictionary Upload
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 21
- name: Install i18next-parser
run: npm i -g i18next-parser@8
- name: Parse translations
run: npx -p i18next-parser i18next -c i18next-parser.config.cjs -o "${{ runner.temp }}/i18next/\$LOCALE/\$NAMESPACE.json"
- name: Install SimpleLocalize CLI
run: curl -s https://get.simplelocalize.io/2.5/install | bash
- name: Upload the dictionary files to SimpleLocalize
run: |
simplelocalize upload \
--apiKey ${{ secrets.SIMPLELOCALIZE_API_KEY }} \
--languageKey=en-US \
--uploadFormat=single-language-json \
--uploadOptions=DELETE_NOT_PRESENT_KEYS,TRIM_LEADING_TRAILING_SPACES \
--uploadPath=${{ runner.temp }}/i18next/{lang}/{ns}.json
5 changes: 1 addition & 4 deletions i18next-parser.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// i18next-parser.config.js

module.exports = {
input: ["./src/**/*.{js,jsx,ts,tsx}"],
contextSeparator: false,
createOldCatalogs: false,
defaultNamespace: "common",
Expand Down Expand Up @@ -33,9 +32,7 @@ module.exports = {
lineEnding: "auto",
locales: ["en-US"],
namespaceSeparator: false,
output: "./tmp/locales/$LOCALE/$NAMESPACE.json",
pluralSeparator: false,
input: undefined,
sort: true,
verbose: false,
failOnWarnings: false,
Expand Down

0 comments on commit a4c4f3f

Please sign in to comment.