docs: add "Use Locize for translation management" recipe#13916
Conversation
✅ Deploy Preview for astro-docs-2 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
|
Hello! Thank you for opening your first PR to Astro’s Docs! 🎉 Here’s what will happen next:
|
There was a problem hiding this comment.
Pull request overview
Adds a new Starlight recipe documenting how to use Locize + locize-cli to download i18n JSON files at build time and wire them into a useTranslations() helper compatible with Astro’s built-in i18n routing.
Changes:
- Adds a new
/recipes/MDX page with end-to-end setup steps forlocize-cli(download + sync). - Documents a simple
ui.tsflattening approach and auseTranslations(lang)helper with interpolation. - Includes guidance/resources for pushing new keys back to Locize.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 2. Add `downloadLocales` and `syncLocales` scripts to your `package.json`. `download` pulls the latest published translations from the Locize CDN into your repo; `sync` uploads any keys present locally but missing in Locize. | ||
|
|
||
| ```json | ||
| { | ||
| "scripts": { | ||
| "downloadLocales": "locize download --project-id=<your-project-id> --ver=latest --cdn-type=standard --clean=true --path=./src/i18n/locales", | ||
| "syncLocales": "locize sync --project-id=<your-project-id> --ver=latest --cdn-type=standard --api-key=<your-write-api-key> --path=./src/i18n/locales --dry=true" |
| import enCommon from './locales/en/common.json' with { type: 'json' }; | ||
| import enIndex from './locales/en/index.json' with { type: 'json' }; | ||
| import deCommon from './locales/de/common.json' with { type: 'json' }; | ||
| import deIndex from './locales/de/index.json' with { type: 'json' }; |
|
Thank you for your contribution even if it doesn't follow either our CONTRIBUTING guide or our PR template...
This should have been a discussion, not a PR. But, anyway, our recipes are meant to walk a reader through completing a working example of a specific task with Astro itself. We don't have the bandwidth to maintain recipes for Astro + X third-party service, with the exception of highly popular tools such as Tailwind because our users ask for it. Hence the importance of a discussion to gauge interest.
This is also not an option unfortunately. We used to do that in the past, but in #13003 we decided to stop to avoid broken links and to only link to our integrations catalog. So, I'm afraid we can't accept this. But, it could be a great content on Locize docs itself in a section explaining how to integrate Locize with third party frameworks or even a blog post. Then, you could submit this as an external resource to Astro Tips. You can also promote the guide in our |
|
Thank you for the clear and honest reasoning — completely understood, and apologies for skipping the Discussion step. I appreciate you taking the time to explain both the scoping rule (recipes for Astro itself, not third-party integrations) and the #13003 precedent on Community-libraries linking. Closing this PR now. I'll explore the Astro Tips external resources submission path and the Thanks again! |
Adds a new
src/content/docs/en/recipes/use-with-locize.mdxrecipe documenting how to sync translations from Locize at build time usinglocize-cli, alongside Astro's built-in i18n routing.Locize is a translation management system created by the maintainers of i18next. It supports the i18next JSON v4 format natively, so the integration with Astro is build-time-only —
locize-clidownloads the latest published JSON intosrc/i18n/locales/{lng}/{ns}.json, and a smalluseTranslations(lang)helper (same pattern as the existing i18n recipe) layers at()function on top.The recipe covers, via
<Steps>:locize-cli(withPackageManagerTabsfor npm/pnpm/yarn)downloadLocales+syncLocalesscripts topackage.json, with a:::notedocumenting Locize's two CDN endpoints (Standard atapi.lite.locize.app, Pro atapi.locize.app)npm run downloadLocalesand the resultingFileTreesrc/i18n/ui.tsuseTranslationshelper insrc/i18n/utils.ts(same pattern as your existing i18n recipe, extended with{name}-style interpolation)[lang]/index.astropage withgetStaticPathsPlus a "Pushing new keys back to Locize" section covering the three workflows (
locize sync,i18next-clistatic extraction, the Locize web app), and a note that runtime saveMissing / live CDN fetch / in-context editing belong inside framework islands via@astrojs/<framework>— not the static layer.Frontmatter uses
i18nReady: trueandtype: recipeper the convention inexternal-links.mdxandanalyze-bundle-size.mdx.Companion assets (in case useful for evaluation): runnable Astro 6 + Locize example repo and a step-by-step blog walkthrough.
Sidebar entry appears automatically alongside the other recipes via the existing
/recipes/index.Happy to adjust scope, wording, code-block style, or sidebar placement if a different shape would land better — or, again, to convert this to an Issue if that's the preferred entry point.