autoglot 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -89,7 +89,8 @@ That's it. The CLI:
|
|
|
89
89
|
|---|---|---|
|
|
90
90
|
| **Next.js (App Router)** | `next-intl` | `src/i18n/routing.ts`, `src/i18n/request.ts`, `src/middleware.ts`, plus a starter `src/app/[locale]/layout.tsx` + `page.tsx` if no `[locale]` segment exists |
|
|
91
91
|
| **Next.js (Pages Router)** | `next-i18next` | Messages + workflow only; prints precise wiring steps (next.config.js i18n block, `appWithTranslation` HOC, `serverSideTranslations` in pages) |
|
|
92
|
-
| **
|
|
92
|
+
| **Expo** | `i18next` + `react-i18next` + `expo-localization` | `src/i18n/index.ts` with device-locale auto-detect on app start |
|
|
93
|
+
| **React Native (bare)** | `i18next` + `react-i18next` | `src/i18n/index.ts` with all locales registered |
|
|
93
94
|
| **Vite + React** | `i18next` + `react-i18next` | `src/i18n.ts` |
|
|
94
95
|
| **Vue / Nuxt** | `vue-i18n` | `src/i18n.ts` (Composition API mode) |
|
|
95
96
|
| **Generic / unknown** | (your choice) | Messages + workflow only — pair with any i18n library that reads JSON |
|
|
@@ -97,8 +98,9 @@ That's it. The CLI:
|
|
|
97
98
|
After init, three things to finish:
|
|
98
99
|
|
|
99
100
|
```bash
|
|
100
|
-
# 1. Install the runtime i18n library
|
|
101
|
-
|
|
101
|
+
# 1. Install the runtime i18n library — or let init do it:
|
|
102
|
+
npx autoglot init --install # detects npm/yarn/pnpm/bun automatically
|
|
103
|
+
# (or run manually, e.g.: npm install next-intl)
|
|
102
104
|
|
|
103
105
|
# 2. Add your Anthropic API key as a repo secret
|
|
104
106
|
gh secret set ANTHROPIC_API_KEY
|
|
@@ -113,12 +115,18 @@ Push → GitHub Action runs → bot commits `messages/<locale>.json` translation
|
|
|
113
115
|
```bash
|
|
114
116
|
npx autoglot # run translation (the default; same as before)
|
|
115
117
|
npx autoglot init # interactive scaffold (above)
|
|
118
|
+
npx autoglot init --install # …and auto-install runtime libs (--pm=pnpm to override)
|
|
116
119
|
npx autoglot add tr ja zh # add new target locales (creates empty JSON files)
|
|
117
120
|
npx autoglot doctor # health check the setup
|
|
118
121
|
npx autoglot extract # scan source for hardcoded strings and suggest keys
|
|
122
|
+
npx autoglot extract --write # …and merge them into messages/en.json (existing keys protected)
|
|
119
123
|
npx autoglot --help # full flag list
|
|
120
124
|
```
|
|
121
125
|
|
|
126
|
+
### Monorepo
|
|
127
|
+
|
|
128
|
+
All commands work from any subdirectory. Drop a `translate.config.json` next to the app whose messages you want translated (e.g. `apps/mobile/translate.config.json`) — paths inside the config resolve against the config file's directory, like eslint/vitest/tsconfig. `autoglot doctor` walks up to the repo root to find your workflow regardless of its filename (`translate.yml`, `translate-mobile.yml`, etc.).
|
|
129
|
+
|
|
122
130
|
## Quickstart — GitHub Action (manual setup)
|
|
123
131
|
|
|
124
132
|
If you'd rather skip `init` and write the workflow yourself:
|
|
@@ -152,6 +160,33 @@ jobs:
|
|
|
152
160
|
|
|
153
161
|
Add `ANTHROPIC_API_KEY` to your repo secrets, drop a `messages/en.json`, create one empty `messages/<locale>.json` per language. On every push the bot will diff, translate, commit the diff back, and post a cost summary.
|
|
154
162
|
|
|
163
|
+
### Want it to run on pull requests instead?
|
|
164
|
+
|
|
165
|
+
Switch the trigger to `pull_request` and tell `actions/checkout` to use the PR's source branch (otherwise the runner checks out a synthetic merge ref that the bot can't push back to):
|
|
166
|
+
|
|
167
|
+
```yaml
|
|
168
|
+
on:
|
|
169
|
+
pull_request:
|
|
170
|
+
paths:
|
|
171
|
+
- messages/en.json
|
|
172
|
+
|
|
173
|
+
jobs:
|
|
174
|
+
translate:
|
|
175
|
+
runs-on: ubuntu-latest
|
|
176
|
+
permissions:
|
|
177
|
+
contents: write
|
|
178
|
+
pull-requests: write
|
|
179
|
+
steps:
|
|
180
|
+
- uses: actions/checkout@v4
|
|
181
|
+
with:
|
|
182
|
+
ref: ${{ github.head_ref }} # ← required for pull_request runs
|
|
183
|
+
- uses: ffcabbar/autoglot@v1
|
|
184
|
+
with:
|
|
185
|
+
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The action detects pull_request events automatically and pushes translations to the PR's source branch. If you forget the `ref:` line, autoglot prints an error explaining how to fix it instead of silently doing the wrong thing.
|
|
189
|
+
|
|
155
190
|
## Quickstart — CLI (no GitHub)
|
|
156
191
|
|
|
157
192
|
```bash
|
|
@@ -271,7 +306,7 @@ In CI, the action then commits the diff and posts the cost summary on the PR.
|
|
|
271
306
|
<details>
|
|
272
307
|
<summary><strong>Does it work with my framework?</strong></summary>
|
|
273
308
|
|
|
274
|
-
Yes. `npx autoglot init` has explicit support for **Next.js (App Router & Pages Router)**, **React Native**, **Vite + React**, and **Vue / Nuxt** — it scaffolds the right runtime setup for each. For anything else (Astro, SvelteKit, Solid, plain HTML, native mobile, server-side, ...) `init` runs in generic mode and just creates the messages + workflow; pair with whichever i18n library you already use that reads JSON.
|
|
309
|
+
Yes. `npx autoglot init` has explicit support for **Next.js (App Router & Pages Router)**, **Expo**, **React Native (bare)**, **Vite + React**, and **Vue / Nuxt** — it scaffolds the right runtime setup for each. For anything else (Astro, SvelteKit, Solid, plain HTML, native mobile, server-side, ...) `init` runs in generic mode and just creates the messages + workflow; pair with whichever i18n library you already use that reads JSON.
|
|
275
310
|
|
|
276
311
|
</details>
|
|
277
312
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autoglot",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "AI-powered i18n translation bot. Diff your en.json on every push, translate only what changed, commit the JSON files back. MIT alternative to Languine, Lokalise, and Crowdin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|