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

Upload translations on builds of master #4002

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ runs:
uses: actions/setup-node@v4
with:
node-version: 18.16.0
- name: Install yarn
run: npm install -g yarn
shell: bash
if: ${{ env.ACT }}
- name: Cache
uses: actions/cache@v4
id: cache
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/i18n-string-extract-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Extract and upload i18n strings

on:
push:
branches:
- master
workflow_dispatch:

jobs:
extract-and-upload-i18n-strings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up environment
uses: ./.github/actions/setup
- name: Configure i18n client
run: |
pip install wlc
- name: Generate i18n strings
run: yarn generate:i18n
- name: Upload i18n strings
run: |
if [[ ! -f packages/desktop-client/locale/en.json ]]; then
echo "File packages/desktop-client/locale/en.json not found. Ensure the file was generated correctly."
exit 1
fi
wlc \
--url https://hosted.weblate.org/api/ \
--key "${{ secrets.WEBLATE_API_KEY_CI_STRINGS }}" \
upload \
--author-name "Actual Budget" \
--author-email "[email protected]" \
--method add \
--input packages/desktop-client/locale/en.json \
actualbudget/actual/en
echo "Translations uploaded"
jfdoming marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions packages/desktop-client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ public/kcab
public/data
public/data-file-index.txt
public/*.wasm

# translations
locale/
2 changes: 1 addition & 1 deletion packages/desktop-client/i18next-parser.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
input: ['src/**/*.{js,jsx,ts,tsx}', '../loot-core/src/**/*.{js,jsx,ts,tsx}'],
output: 'src/locale/$LOCALE.json',
output: 'locale/$LOCALE.json',
locales: ['en'],
sort: true,
keySeparator: false,
Expand Down
9 changes: 8 additions & 1 deletion packages/desktop-client/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ import { initReactI18next } from 'react-i18next';
import i18n from 'i18next';
import resourcesToBackend from 'i18next-resources-to-backend';

const languages = import.meta.glob('/locale/*.json');

const loadLanguage = (language: string) => {
return import(`./locale/${language}.json`);
const path = `/locale/${language}.json`;
if (!Object.hasOwn(languages, path)) {
console.error(`Unknown locale ${language}`);
throw new Error(`Unknown locale ${language}`);
}
return languages[path]();
};

i18n
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/4002.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [jfdoming]
---

Upload translations after changes are merged
Loading