question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

i18n: Support default language strings

See original GitHub issue

Detailed 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: image

Then switching the language to Chinese which hasn’t been fully translated yet (pending PII) would end up looking like this:

image

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:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
stanislavgeorgievcommented, Dec 3, 2018

Thanks @cal-smith for the quick replies and fixes. 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"
	},
});
0reactions
carbon-botcommented, Dec 4, 2018

🎉 This issue has been resolved in version 2.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

i18n: Support default language strings · Issue #301 - GitHub
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...
Read more >
Rails Internationalization (I18n) API - Ruby on Rails Guides
The I18n library will use English as a default locale, i.e. if a different locale is not set, :en will be used for...
Read more >
The Java i18n Guide You've Been Waiting For | Phrase
As you may already know, the default supported i18n services exposed by the Java Development Kit (JDK) is the Locale class.
Read more >
default language and string translations - Drupal Groups
Some strings are English, some are American English, some are bad English, few are English with typos :) My proposal is fix in...
Read more >
Localizing strings in iOS: default (fallback) language?
Perhaps this should help? -- iPhone: localization / internationalization default strings file. It should fallback to English by default.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found