generated from redhat-developer/new-project-template
-
Notifications
You must be signed in to change notification settings - Fork 55
RHIDP-8635-1 - Comprehensive documentation for developers on adding localization support to custom plugins #1443
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
Open
Gerry-Forde
wants to merge
61
commits into
redhat-developer:main
Choose a base branch
from
Gerry-Forde:RHIDP-8635-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
19e7af3
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde 9a243fa
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde d902569
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde 348bc29
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde 2822628
Merge branch 'redhat-developer:main' into RHIDP-8635-1
Gerry-Forde fe7f1d5
Update modules/customizing-the-appearance/proc-adding-localization-to…
Gerry-Forde a0336d1
Update modules/customizing-the-appearance/proc-adding-localization-to…
Gerry-Forde 31ea439
Update modules/customizing-the-appearance/proc-overriding-translation…
Gerry-Forde 4a64905
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde fead28b
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde 0ac0c53
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde 7128efc
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde 9e9d9b6
Update modules/customizing-the-appearance/proc-overriding-translation…
Gerry-Forde 8a80b35
Update modules/customizing-the-appearance/proc-overriding-translation…
Gerry-Forde c27782c
Update modules/customizing-the-appearance/proc-overriding-translation…
Gerry-Forde a357528
Update modules/customizing-the-appearance/proc-overriding-translation…
Gerry-Forde 851d313
Update modules/customizing-the-appearance/con-language-persistence.adoc
Gerry-Forde 863e698
Update modules/customizing-the-appearance/proc-overriding-translation…
Gerry-Forde a854520
Update modules/customizing-the-appearance/proc-overriding-translation…
Gerry-Forde 1d2299b
Update modules/customizing-the-appearance/proc-overriding-translation…
Gerry-Forde f80edec
Update modules/customizing-the-appearance/proc-overriding-translation…
Gerry-Forde b4acbb6
Update modules/customizing-the-appearance/proc-overriding-translation…
Gerry-Forde 27f76d4
Update modules/customizing-the-appearance/proc-overriding-translation…
Gerry-Forde c2d345e
Update modules/customizing-the-appearance/ref-best-practices-for-loca…
Gerry-Forde 744683b
Update modules/customizing-the-appearance/proc-overriding-translation…
Gerry-Forde a32ba21
Update modules/customizing-the-appearance/proc-adding-localization-to…
Gerry-Forde 0285a12
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde 77316ca
Merge branch 'main' into RHIDP-8635-1
Gerry-Forde 7bc89c6
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde c7461be
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde 064d75b
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde 91c380a
Merge branch 'main' into RHIDP-8635-1
Gerry-Forde 63b8069
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde b8fa956
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde a6cde1f
Update modules/customizing-the-appearance/proc-enabling-localization-…
Gerry-Forde cac8ecd
Update modules/configuring-a-floating-action-button/con-localization-…
Gerry-Forde b433927
Update modules/configuring-a-floating-action-button/con-localization-…
Gerry-Forde 5467d90
Update modules/customizing-the-appearance/proc-enabling-localization-…
Gerry-Forde fb5e8a4
Update modules/customizing-the-appearance/proc-enabling-localization-…
Gerry-Forde 8d43fec
Update modules/customizing-the-appearance/proc-overriding-translation…
Gerry-Forde fab4990
Update modules/customizing-the-appearance/proc-enabling-localization-…
Gerry-Forde 0ed67ed
Update modules/configuring-a-floating-action-button/con-localization-…
Gerry-Forde 6d9b857
Update modules/customizing-the-appearance/proc-enabling-localization-…
Gerry-Forde 7e76a5f
Update modules/configuring-a-floating-action-button/con-localization-…
Gerry-Forde 7e26249
Update modules/configuring-a-floating-action-button/con-localization-…
Gerry-Forde 4afcc34
Update modules/configuring-a-floating-action-button/con-localization-…
Gerry-Forde 5550874
Update modules/configuring-a-floating-action-button/proc-configuring-…
Gerry-Forde 959a988
Update modules/configuring-a-floating-action-button/proc-configuring-…
Gerry-Forde 629fd9f
Update modules/customizing-the-appearance/con-language-persistence.adoc
Gerry-Forde f0cb2d3
Merge branch 'main' into RHIDP-8635-1
Gerry-Forde eee8f7f
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde 1784af9
Merge branch 'main' into RHIDP-8635-1
Gerry-Forde ad0722c
Merge branch 'redhat-developer:main' into RHIDP-8635-1
Gerry-Forde 4e5f01e
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde 5908549
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde 20814c7
Merge branch 'main' into RHIDP-8635-1
Gerry-Forde 1cdf284
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde 2b31419
RHIDP-8635-1 - Comprehensive documentation for developers on adding l…
Gerry-Forde a9120d4
RHIDP-8635-1 - [testday] Fix typo in localisation docs
Gerry-Forde 3b42cd3
RHIDP-8635-1 - [testday] Localization: Add link to oc installation
Gerry-Forde 6ef43d3
RHIDP-8634-2 - [testday] Localization: Update enablement and language…
Gerry-Forde 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
Some comments aren't visible on the classic Files Changed page.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| :_mod-docs-content-type: ASSEMBLY | ||
| :context: assembly-localization-in-rhdh | ||
|
|
||
| [id="assembly-localization-in-rhdh_{context}"] | ||
| = Localization in {product} | ||
|
|
||
| include::modules/customizing-the-appearance/proc-enabling-localization-in-rhdh.adoc[leveloffset=+1] | ||
|
|
||
| include::modules/customizing-the-appearance/proc-select-rhdh-language.adoc[leveloffset=+1] | ||
|
|
||
| include::modules/customizing-the-appearance/con-language-persistence.adoc[leveloffset=+2] | ||
|
|
||
| // include::modules/customizing-the-appearance/proc-enabling-localization-in-quickstarts.adoc[leveloffset=+1] | ||
|
|
||
| // include::modules/customizing-the-appearance/proc-enabling-localization-in-sidebar-items.adoc[leveloffset=+1] | ||
|
|
||
| //include::modules/customizing-the-appearance/proc-enabling-localization-in-floating-action-button.adoc[leveloffset=+1] | ||
|
|
||
| == Localization support for plugins | ||
|
|
||
| include::modules/customizing-the-appearance/proc-overriding-translations.adoc[leveloffset=+2] | ||
|
|
||
| include::modules/customizing-the-appearance/ref-best-practices-for-localization.adoc[leveloffset=+2] | ||
|
|
||
| include::modules/customizing-the-appearance/proc-adding-localization-to-custom-plugins.adoc[leveloffset=+2] | ||
|
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions
60
...ting-action-button/con-localization-support-for-the-floating-action-button.adoc
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,60 @@ | ||
| [id="proc-enabling-localization-in-floating-action-button_{context}"] | ||
| = Enabling floating action button localization in {product-very-short} | ||
|
|
||
| You can enable translation key support for floating action buttons, so that users can onboard in their preferred language. In {product-short}, all existing and newly created floating action buttons support localization using dedicated translation keys. | ||
|
|
||
| The Global Floating Action Button plugin supports internationalization (i18n) through translation keys. You can use `labelKey` and `toolTipKey` properties to provide translation keys instead of static text. | ||
|
|
||
| The plugin provides the following built-in translation keys organized under the `fab` namespace: | ||
|
|
||
| * `fab.create.label` - "Create" | ||
| * `fab.create.tooltip` - "Create entity" | ||
| * `fab.docs.label` - "Docs" | ||
| * `fab.docs.tooltip` - "Documentation" | ||
| * `fab.apis.label` - "APIs" | ||
| * `fab.apis.tooltip` - "API Documentation" | ||
| * `fab.github.label` - "GitHub" | ||
| * `fab.github.tooltip` - "GitHub Repository" | ||
| * `fab.bulkImport.label` - "Bulk Import" | ||
| * `fab.bulkImport.tooltip` - "Register multiple repositories in bulk" | ||
| * `fab.quay.label` - "Quay" | ||
| * `fab.quay.tooltip` - "Quay Container Registry" | ||
|
|
||
| The plugin includes translations for the following supported languages: | ||
|
|
||
| * English (default) | ||
| // * German (de) | ||
| * French (fr) | ||
| // * Spanish (es) | ||
|
|
||
| // [NOTE] | ||
| // ==== | ||
| // To add localization support for a new floating action button item, you can add any arbitrary key name for the `labelKey` and `toolTipKey` properties and provide corresponding translations for those keys. | ||
|
|
||
| // If you add a new floating action button item, you can add localization support by adding an arbitary label key and tool tip key | ||
|
|
||
| // ==== | ||
|
|
||
| To ensure backward compatibility while providing translation support when available, the following order is used to resolve string translations: | ||
|
|
||
| . If the `labelKey` is provided, the plugin will attempt to resolve the translation key | ||
| . If the translation key is found, it will be used as the label | ||
| . If the translation key is not found, the plugin will fall back to the label property | ||
|
|
||
| [NOTE] | ||
| ==== | ||
| The same logic applies to `toolTipKey` and `toolTip`. | ||
| ==== | ||
|
|
||
| == Internal translation implementation | ||
| The plugin uses a centralized translation system where: | ||
|
|
||
| * The `useTranslation()` hook is called in components that render floating action buttons to ensure proper translation context initialization | ||
| * The translation function (`t`) is passed down to child components that need to resolve translation keys | ||
| * This internal architecture prevents infinite re-render loops and ensures stable component rendering | ||
| * All components that use `CustomFab` must provide the translation function as a prop | ||
|
|
||
| [NOTE] | ||
| ==== | ||
| When extending or modifying the plugin components, ensure that the `useTranslation()` hook is called in parent components and the `t` prop is passed to `CustomFab` instances to maintain proper translation functionality and prevent rendering issues. | ||
| ==== | ||
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 |
|---|---|---|
|
|
@@ -203,3 +203,43 @@ To configure a floating action button as a dynamic plugin, complete any of the f | |
| text: Bulk import | ||
| ---- | ||
| `frontend:mountPoints:importName`:: Enter the import name with an associated component to the mount point. | ||
|
|
||
| = Translation support | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @its-mitesh-kumar Could you please provide a technical review of this section of the guide. |
||
| The Global Floating Action Button plugin supports internationalization (i18n) through translation keys. You can use `labelKey` and `toolTipKey` properties to provide translation keys instead of static text. | ||
|
|
||
| Example for using translation keys in dynamic configuration: | ||
| [source,yaml] | ||
| ---- | ||
| - package: ./dynamic-plugins/dist/red-hat-developer-hub-backstage-plugin-global-floating-action-button | ||
| disabled: false | ||
| pluginConfig: | ||
| dynamicPlugins: | ||
| frontend: | ||
| red-hat-developer-hub.backstage-plugin-global-floating-action-button: | ||
| translationResources: | ||
| - importName: globalFloatingActionButtonTranslations | ||
| ref: globalFloatingActionButtonTranslationRef | ||
| mountPoints: | ||
| - mountPoint: application/listener | ||
| importName: DynamicGlobalFloatingActionButton | ||
| - mountPoint: global.floatingactionbutton/config | ||
| importName: NullComponent | ||
| config: | ||
| icon: github | ||
| label: 'GitHub' # Fallback text | ||
| labelKey: 'fab.github.label' # Translation key | ||
| toolTip: 'GitHub Repository' # Fallback text | ||
| toolTipKey: 'fab.github.tooltip' # Translation key | ||
| to: https://github.com/redhat-developer/rhdh-plugins | ||
| - mountPoint: global.floatingactionbutton/config | ||
| importName: NullComponent | ||
| config: | ||
| color: 'success' | ||
| icon: search | ||
| label: 'Create' # Fallback text | ||
| labelKey: 'fab.create.label' # Translation key | ||
| toolTip: 'Create entity' # Fallback text | ||
| toolTipKey: 'fab.create.tooltip' # Translation key | ||
| to: '/create' | ||
| showLabel: true | ||
| ---- | ||
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
27 changes: 27 additions & 0 deletions
27
modules/customizing-the-appearance/con-language-persistence.adoc
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,27 @@ | ||
| :_mod-docs-content-type: CONCEPT | ||
|
|
||
| [id="con-language-persistence_{context}"] | ||
| = Language persistence | ||
|
|
||
| When you change the language in the UI, your preference is saved to storage. On next login or refresh, your chosen language setting is restored. Guest users cannot persist language preferences. | ||
|
|
||
| Default language selection uses the following priority order: | ||
|
|
||
| . *Browser language priority*: The system first checks the user's browser language preferences to provide a personalized experience. | ||
|
|
||
| . *Configuration priority*: If no browser language matches the supported locales, the `defaultLocale` from the `i18n` configuration is used as a fallback. | ||
|
|
||
| . *Fallback priority*: If neither browser preferences nor configuration provide a match, defaults to `en`. | ||
|
|
||
| {product} automatically saves and restores user language settings across browser sessions. This feature is enabled by default and uses database storage. To opt-out and use browser storage instead, add the following to your `{my-app-config-file}` configuration file: | ||
| [source,yaml,subs="+quotes"] | ||
| ---- | ||
| userSettings: | ||
| persistence: browser | ||
| ---- | ||
|
|
||
| where: | ||
|
|
||
| userSettings:persistence:: | ||
| Enter `browser` to opt-out and use browser local storage. Optionally, set this value to `database` to persist across browsers and devices. This is the default setting and does not require this configuration to be set. | ||
|
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should also be mentioned that if users want to support localization for a new FAB item, add any arbitrary keys for labelKey and toolTipKey, they must also provide corresponding translations for those keys. This process is similar to what’s described in the Quickstart documentation:
Enabling localization in Quickstarts 3. In your translation file, map the keys from the first step to the localized strings for each supported language.
allTranslations.jsoncan look like