-
Notifications
You must be signed in to change notification settings - Fork 334
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
Expand internationalisation logic to add pluralisation #2804
Comments
A quick thought as I read the feedback: isn't this point more linked to the character count component itself (where the meaning of |
So, I tried to wrap my head around what would need to happen based on the spike and it seems like it's a two part update: A.
Feels like this can be implemented on its own ahead ot the changes to the B. Then there's the meaty bit of updating
|
The latter, I believe – there's no need for a I think the intent was to include
I think there are a few routes we could go down:
With the first two options I think this might mean the component class working out the locale and passing it to the i18n object? Unless we pass the I'm not 100% sure about the second option as it'd mean allowing for both a
I'd suggest we can add this in the future if we find there's a need for it.
Suspect @querkmachine is the best person to answer these ones!
I think number formatting should be tackled separately in #2568 |
I should have exemplified there for clarity, sorry. The spike was indeed receiving options as two keys in an object: {
locale: "en",
translations: {
key1: 'Translated string'
}
} In its current state, the constructor expects the translations straight away: {
key1: 'Translated string'
} I was wondering if this was because of putting in just the code to make tests pass or another decision (as having
At the I like the idea of looking up the DOM for the closest Unrelated: All that talk about locale made me think we should likely consider it for the data attributes expected by the character count (added a comment to that effect on that issue).
👍🏻 x3 😄 |
Unsure! Possibly another one for @querkmachine when it's back tomorrow…
All good points. As you suggest, maybe we should keep it simple and expect an explicit If we were going to go down that route I think I'd prefer to hardcode 'en' as the fallback rather than looking at the document lang, purely to avoid encouraging users adding a |
For some background context: Part of my reasoning for including I was envisaging a situation where a user might need to translate a component into a language which the hardcoded rules don't support; for example, Mongolian. However, Mongolian has the same plural forms as English, so a user could choose to use Mongolian translation strings but set the Since then I've come to think that this functionality is probably extraneous and won't be needed by 98+% of users. It will also not be necessary when we remove JS support from IE, as the appropriate plural form information will already be available in evergreen browsers as If we opt to keep it as a configuration option, I worry that it's more likely to cause confusion unless we make the intended use more explicit: such as splitting the option in two and naming them something like So, my thinking here was that, rather than allowing the user to provide a My reasoning for this is that the By making My hypothesis is that doing it this way shouldn't add unnecessary code weight as we already include an |
For the other questions I just noticed (cc: @romaricpascal)
Avoiding polyfills and their dependencies and simplicity of implementation. We don't actually need a lot of the PluralRules functionality at the moment, we only need to support positive integers (not negatives, decimals, and ranges as the spec supports).
I included a whole bunch of languages in the spike mainly for completion's sake (i.e. the work is already done and there if we need it). In practice, services are only provided in a few different languages—English, Welsh, and very occassionally Arabic—although GOV.UK content pages use many more. I imagined we would be able to cut down on the size of these if and when we had a better idea of what languages to prioritise. We don't have any existing architecture for Frontend to conditionally load certain files, or having users load specific configuration files, which is why they're all bundled together for now. We've discussed using dynamic |
What
Expand our internationalisation logic to handle pluralisation. This will allow users to be able to translate hardcoded strings in the character count component.
For example: “You have 1 character remaining” vs “You have 20 characters remaining”
Needs to handle languages other than English, that may have different plural forms, see https://cldr.unicode.org/index/cldr-spec/plural-rules
Why
Some components will need to be able to switch between different strings based on the value of something, e.g: the character count component will need to switch the count message based on the count (see example above)
Who needs to work on this
Developers
Who needs to review this
Developers
Done when
The text was updated successfully, but these errors were encountered: