This example shows how to use LocaleSync in a React project using react-i18next for internationalization.
my-react-app/
├── public/
│ └── locales/
│ ├── en.json # Source locale (English)
│ ├── pl.json # Polish (partial)
│ ├── de.json # German (partial)
│ └── fr.json # French (partial)
├── src/
│ ├── i18n.ts # i18next configuration
│ └── ...
├── package.json
└── .github/
└── workflows/
└── locale-check.yml
Install LocaleSync globally (or per-project via pipx):
# Option 1: pipx (recommended for dev machines)
pipx install git+https://github.com/polprog-tech/LocaleSync.git
# Option 2: pip
pip install git+https://github.com/polprog-tech/LocaleSync.gitnpm run locales:check
# or directly:
locale-sync check public/localesnpm run locales:sync
# or directly:
locale-sync sync public/localesnpm run locales:translate
# or directly:
locale-sync translate public/localesnpm run locales:scan
# or with auto-discovery from project root:
locale-sync scan .Add these scripts to your package.json:
{
"scripts": {
"locales:check": "locale-sync check public/locales",
"locales:sync": "locale-sync sync public/locales",
"locales:translate": "locale-sync translate public/locales",
"locales:scan": "locale-sync scan public/locales"
}
}The included .github/workflows/locale-check.yml workflow:
- Triggers on PRs that modify
public/locales/** - Installs LocaleSync from GitHub
- Runs
locale-sync checkto verify all translations are complete - Runs
locale-sync translate --dry-runto preview what would be added
Typical src/i18n.ts setup for react-i18next:
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import HttpBackend from 'i18next-http-backend';
i18n
.use(HttpBackend)
.use(initReactI18next)
.init({
fallbackLng: 'en',
supportedLngs: ['en', 'pl', 'de', 'fr'],
backend: {
loadPath: '/locales/{{lng}}.json',
},
interpolation: {
escapeValue: false,
},
});
export default i18n;- Add new keys to
en.jsonduring development - Run
npm run locales:checkto see what's missing - Run
npm run locales:translateto auto-translate missing keys - Review generated translations and adjust as needed
- Commit the updated locale files
For the full React guide with CI examples and team conventions, see docs/react-guide.md.