-
-
Notifications
You must be signed in to change notification settings - Fork 842
Expose FS translation system to plugins #2578
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
Merged
delucis
merged 32 commits into
withastro:main
from
HiDeoo:hd-refactor-inject-translations
Feb 15, 2025
Merged
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
5eb0121
feat: exposes fs translation system to plugins
HiDeoo 9844dc1
feat: update ec `getBlockLocale()` with the change of 2551
HiDeoo 3b79cce
refactor: rename plugin hooks
HiDeoo 8f0acd8
Merge branch 'main' into hd-refactor-inject-translations
HiDeoo 0d73832
fix: demo plugin lock file
HiDeoo 8ddfb98
fix: add async hook comment
HiDeoo 850d3f1
fix: add ec `pathToLang` comment
HiDeoo 57e8a06
docs: tweak `useTranslations` documentation
HiDeoo c40f599
refactor `pathToLang()` → `absolutePathToLang()`
HiDeoo fe6e68c
test: add test to ensure DocSearch plugin use `config:setup` hook
HiDeoo 5ddf2f1
feat: add `HookParameters` utility type
HiDeoo 6f41499
fix: remove `absolutePathToLang()` error
HiDeoo 60dbc9c
fix: add `starlight-links-validator` patch
HiDeoo b1cb641
chore: add `HookParameters` changeset
HiDeoo 71cbdb5
fix: remove temporary `starlight-links-validator` patch
HiDeoo 5aab231
docs: update `useTranslations()` example
HiDeoo 36ef34f
docs: mention BCP-47 in `useTranslations()` description
HiDeoo 80af330
Merge branch 'main' into pr/2578
delucis 56baf37
Update Astro version in demo plugin
delucis f11ec45
Discard changes to pnpm-lock.yaml
delucis 8f62051
Fix lock file
delucis 3cd90c5
Merge branch 'main' into hd-refactor-inject-translations
delucis 8bd4a1d
docs: apply suggestions
HiDeoo e00a3b1
refactor: destructure some variables
HiDeoo 94927f3
feat: use `config:setup` hook in docsearch plugin
HiDeoo 8e87088
chore: remove demo plugin
HiDeoo f543ed9
chore: remove unused import
HiDeoo e80caa4
chore: bump starlight peer dependency version in docsearch plugin
HiDeoo 498c268
Merge branch 'main' into hd-refactor-inject-translations
delucis 1c4b186
Merge branch 'main' into hd-refactor-inject-translations
delucis 37398b2
Merge branch 'main' into hd-refactor-inject-translations
delucis a6661b3
Bump Starlight peer dep for Doscsearch package to 0.32
delucis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@astrojs/starlight': minor | ||
| --- | ||
|
|
||
| Adds a new [`HookParameters`](https://starlight.astro.build/reference/plugins/#hooks) utility type to get the type of a plugin hook’s arguments. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| --- | ||
| '@astrojs/starlight': minor | ||
| --- | ||
|
|
||
| Exposes the built-in localization system in the Starlight plugin `config:setup` hook. | ||
|
|
||
| ⚠️ **BREAKING CHANGE:** | ||
|
|
||
| This addition changes how Starlight plugins add or update translation strings used in Starlight’s localization APIs. | ||
| Plugins previously using the [`injectTranslations()`](https://starlight.astro.build/reference/plugins/#injecttranslations) callback function from the plugin [`config:setup`](https://starlight.astro.build/reference/plugins/#configsetup) hook should now use the same function available in the [`i18n:setup`](https://starlight.astro.build/reference/plugins/#i18nsetup) hook. | ||
|
|
||
| ```diff | ||
| export default { | ||
| name: 'plugin-with-translations', | ||
| hooks: { | ||
| - 'config:setup'({ injectTranslations }) { | ||
| + 'i18n:setup'({ injectTranslations }) { | ||
| injectTranslations({ | ||
| en: { | ||
| 'myPlugin.doThing': 'Do the thing', | ||
| }, | ||
| fr: { | ||
| 'myPlugin.doThing': 'Faire le truc', | ||
| }, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@astrojs/starlight': minor | ||
| --- | ||
|
|
||
| Adds a new [`useTranslations()`](https://starlight.astro.build/reference/plugins/#usetranslations) callback function to the Starlight plugin `config:setup` hook to generate a utility function to access UI strings for a given language. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| --- | ||
| '@astrojs/starlight': minor | ||
| --- | ||
|
|
||
| Deprecates the Starlight plugin `setup` hook in favor of the new `config:setup` hook which provides the same functionality. | ||
|
|
||
| ⚠️ **BREAKING CHANGE:** | ||
|
|
||
| The Starlight plugin `setup` hook is now deprecated and will be removed in a future release. Please update your plugins to use the new `config:setup` hook instead. | ||
|
|
||
| ```diff | ||
| export default { | ||
| name: 'plugin-with-translations', | ||
| hooks: { | ||
| - 'setup'({ config }) { | ||
| + 'config:setup'({ config }) { | ||
| // Your plugin configuration setup code | ||
| }, | ||
| }, | ||
| }; | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| '@astrojs/starlight-docsearch': minor | ||
| --- | ||
|
|
||
| ⚠️ **BREAKING CHANGE:** The minimum supported version of Starlight is now 0.31.0 | ||
|
|
||
| Please use the `@astrojs/upgrade` command to upgrade your project: | ||
|
|
||
| ```sh | ||
| npx @astrojs/upgrade | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@astrojs/starlight': minor | ||
| --- | ||
|
|
||
| Adds a new [`absolutePathToLang()`](https://starlight.astro.build/reference/plugins/#absolutepathtolang) callback function to the Starlight plugin `config:setup` to get the language for a given absolute file path. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.