From 571259803270307be5c1cb7ae6832d64ab9359dc Mon Sep 17 00:00:00 2001 From: Anthony Bailey Date: Fri, 5 Sep 2025 14:19:59 +0100 Subject: [PATCH 1/3] Add Spanish locale testing configuration - Configure netlify.toml to enable all locales for l10n* branches - Add Spanish (es) to default-settings.js for testing - Update L10N.md with new locale testing workflow --- L10N.md | 59 +++++++++++++++++++++++++++--- netlify.toml | 5 +++ project.inlang/default-settings.js | 2 +- 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/L10N.md b/L10N.md index 2cc04f57d..e18603953 100644 --- a/L10N.md +++ b/L10N.md @@ -198,7 +198,7 @@ l10n-cage/ 4. **L10n is generated automatically** in CI/CD on the appropriate cage branch 5. **Preview l10n results** in staging before merging -**Current limitation**: While main branch is locked to en-only locale, target your pull requests to `l10-preview` or similar branches that have all locales enabled in order to have l10ns automatically captured. +**Testing new locales**: To test a new locale before adding it to production, create a branch starting with `l10n` (e.g., `l10n-es` for Spanish). These branches automatically get `PARAGLIDE_LOCALES="all"` via `netlify.toml`, allowing you to preview all locales defined in `default-settings.js`. ### L10n Development @@ -252,20 +252,67 @@ This lets you reuse expensive LLM-generated content across different feature bra ### Adding New Locales -1. **Add locale to configuration**: +#### Testing Before Production + +To test a new locale without affecting production: + +1. **Create a test branch** starting with `l10n`: + + ```bash + git checkout -b l10n-fr origin/main # For testing French + ``` + +2. **Add locale to configuration**: ```javascript // project.inlang/default-settings.js - locales: ['en', 'nl', 'de', 'fr'] // Add 'fr' + locales: ['en', 'de', 'nl', 'fr'] // Add 'fr' to existing locales ``` -2. **Estimate work locally**: + Note: You can temporarily remove other non-English locales during development to speed up builds, but this makes the merge to main less straightforward. + +3. **Estimate work locally** (optional but recommended): + + ```bash + PARAGLIDE_LOCALES=all pnpm l10n --dry-run --verbose + ``` + + This shows what translations will be generated and estimated costs. + +4. **Push to trigger preview**: ```bash - PARAGLIDE_LOCALES=en,fr pnpm l10n --dry-run --verbose + git add -A && git commit -m "Test French locale" + git push -u origin l10n-fr ``` -3. You could **perform it locally** or **through a pull request** + Netlify will build a preview with all defined locales enabled (via `netlify.toml` context). + +5. **The l10n cage mirrors your branch**: Translations are stored in a matching `l10n-fr` branch of the paraglide repository. + +#### Launching to Production + +Once tested, you have two options: + +**Option A: Fresh translations** + +- Merge `l10n-fr` to main +- Production regenerates translations + +**Option B: Preserve tested translations** + +- First merge paraglide's `l10n-fr` to paraglide's main +- Then merge website's `l10n-fr` to main +- Production uses your tested translations + +#### Local Testing + +For local testing with API key: + +```bash +PARAGLIDE_LOCALES=en,fr pnpm l10n --dry-run --verbose # Estimate work and costs +PARAGLIDE_LOCALES=en,fr pnpm l10n # Generate translations +``` ## Troubleshooting diff --git a/netlify.toml b/netlify.toml index 94e42eae4..5f5550019 100644 --- a/netlify.toml +++ b/netlify.toml @@ -24,3 +24,8 @@ [dev] command = "pnpm dev" port = 37572 + +# Configuration for l10n testing branches +# Any branch starting with "l10n" will use all locales defined in default-settings.js +[context."l10n*".environment] + PARAGLIDE_LOCALES = "all" diff --git a/project.inlang/default-settings.js b/project.inlang/default-settings.js index 9887dd42f..4a74d062d 100644 --- a/project.inlang/default-settings.js +++ b/project.inlang/default-settings.js @@ -7,7 +7,7 @@ export default { $schema: 'https://inlang.com/schema/project-settings', baseLocale: 'en', - locales: ['en', 'de', 'nl'], + locales: ['en', 'es'], modules: [ 'https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js', 'https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@latest/dist/index.js', From 5119c1cd64859e56aa93c9b910742f00cd0551eb Mon Sep 17 00:00:00 2001 From: Anthony Bailey Date: Fri, 5 Sep 2025 14:53:21 +0100 Subject: [PATCH 2/3] Fix l10n testing configuration - Use specific branch context (wildcards not supported by Netlify) - Set PARAGLIDE_LOCALES to 'es' for faster, focused testing - Update docs to clarify testing branches aren't merged directly --- L10N.md | 38 +++++++++++++++++++++++--------------- netlify.toml | 8 ++++---- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/L10N.md b/L10N.md index e18603953..56f040b82 100644 --- a/L10N.md +++ b/L10N.md @@ -256,7 +256,7 @@ This lets you reuse expensive LLM-generated content across different feature bra To test a new locale without affecting production: -1. **Create a test branch** starting with `l10n`: +1. **Create a test branch** with a specific name like `l10n-fr`: ```bash git checkout -b l10n-fr origin/main # For testing French @@ -269,9 +269,18 @@ To test a new locale without affecting production: locales: ['en', 'de', 'nl', 'fr'] // Add 'fr' to existing locales ``` - Note: You can temporarily remove other non-English locales during development to speed up builds, but this makes the merge to main less straightforward. + Note: You can temporarily remove other non-English locales during development to speed up builds. -3. **Estimate work locally** (optional but recommended): +3. **Add branch context to netlify.toml**: + + ```toml + [context.l10n-fr.environment] + PARAGLIDE_LOCALES = "fr" # Just test French + English + ``` + + Note: Netlify doesn't support wildcards in context names, so each test branch needs its own context entry. Setting just "fr" builds faster and makes the test focus clear. + +4. **Estimate work locally** (optional but recommended): ```bash PARAGLIDE_LOCALES=all pnpm l10n --dry-run --verbose @@ -279,31 +288,30 @@ To test a new locale without affecting production: This shows what translations will be generated and estimated costs. -4. **Push to trigger preview**: +5. **Push to trigger preview**: ```bash git add -A && git commit -m "Test French locale" git push -u origin l10n-fr ``` - Netlify will build a preview with all defined locales enabled (via `netlify.toml` context). + Create a draft PR to trigger Netlify's preview build with your locale enabled. -5. **The l10n cage mirrors your branch**: Translations are stored in a matching `l10n-fr` branch of the paraglide repository. +6. **The l10n cage mirrors your branch**: Translations are stored in a matching `l10n-fr` branch of the paraglide repository. #### Launching to Production -Once tested, you have two options: - -**Option A: Fresh translations** +Once testing is complete: -- Merge `l10n-fr` to main -- Production regenerates translations +1. **Add the locale to main** by editing `project.inlang/default-settings.js` directly on main +2. **Choose your translation strategy**: -**Option B: Preserve tested translations** + **Option A: Fresh translations** + - Let production regenerate translations from scratch -- First merge paraglide's `l10n-fr` to paraglide's main -- Then merge website's `l10n-fr` to main -- Production uses your tested translations + **Option B: Preserve tested translations** + - First merge paraglide's `l10n-fr` branch to paraglide's main + - Production will use your tested and reviewed translations #### Local Testing diff --git a/netlify.toml b/netlify.toml index 5f5550019..8ef7d3a6e 100644 --- a/netlify.toml +++ b/netlify.toml @@ -25,7 +25,7 @@ command = "pnpm dev" port = 37572 -# Configuration for l10n testing branches -# Any branch starting with "l10n" will use all locales defined in default-settings.js -[context."l10n*".environment] - PARAGLIDE_LOCALES = "all" +# Spanish locale testing branch +[context.l10n-es.environment] + PARAGLIDE_LOCALES = "es" + From 26a31f1d9820d811f01838700116d67990359524 Mon Sep 17 00:00:00 2001 From: Anthony Bailey Date: Sun, 7 Sep 2025 04:50:38 +0100 Subject: [PATCH 3/3] Fix unlocalized logo link - use localizeHref for homepage The logo link was hardcoded to '/' which meant Spanish users on /es/ pages would be taken back to the English homepage when clicking the logo. Now uses localizeHref('/') to properly localize the link, so Spanish users stay in /es/ when clicking the logo. Fixes part of the issues described in #448 --- src/routes/header.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/header.svelte b/src/routes/header.svelte index fac1422b0..73b381d50 100644 --- a/src/routes/header.svelte +++ b/src/routes/header.svelte @@ -28,7 +28,7 @@