i18n: Support default language strings
See original GitHub issueDetailed description
Describe in detail the issue you’re having.
We’re using i18n.set()
to provide translated strings which works great. The issue is that if we don’t have the Carbon string keys in our files then the Carbon components won’t show any text.
For example, providing English strings as the following:
"PAGINATION": {
"ITEMS_PER_PAGE": "Items per page:",
"OPEN_LIST_OF_OPTIONS": "Open list of options",
"BACKWARD": "Backward",
"FORWARD": "Forward",
"TOTAL_ITEMS": "{{start}}-{{end}} of {{total}} items",
"TOTAL_PAGES": "{{current}} of {{last}} pages"
},
would end rendering correctly as:
Then switching the language to Chinese which hasn’t been fully translated yet (pending PII) would end up looking like this:
Is this a feature request (new component, new icon), a bug, or a general issue?
Feature request
Is this issue related to a specific component?
i18n
What did you expect to happen? What happened instead? What would you like to see changed?
If a string key hasn’t been found then fall back to the default English strings that come along with Carbon. Another option to make it even more flexible is allow users to set the default strings (which initially are set to the Carbon ones)
What browser are you working in?
Any
What version of the Carbon Design System are you using?
2.4.0
What offering/product do you work on? Any pressing ship or release dates we should be aware of?
ADI
Reproduce
This should show the problem right away as the new keys for TOTAL_ITEMS and TOTAL_PAGES are missing:
i18n.set({
"PAGINATION": {
"ITEMS_PER_PAGE": "Eléments par page :",
"BACKWARD": "Vers l'arrière",
"FORWARD": "Vers l'avant"
},
});
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
Thanks @cal-smith for the quick replies and fixes. This should show the problem right away as the new keys for
TOTAL_ITEMS
andTOTAL_PAGES
are missing:🎉 This issue has been resolved in version 2.4.1 🎉
The release is available on:
Your semantic-release bot 📦🚀