-
Notifications
You must be signed in to change notification settings - Fork 841
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
Some controls needs to support i18n #738
Comments
@pugnascotia Could you give an example of what this might look like from a consumption standpoint? I'd like to see what the interface looks like from the outside, and what these props would look like. |
So I'm thinking that EUI would push all responsibility for generating the correct text to the app, so no locale-switch, any of that because it's tied into how your app handles i18n. That just leaves picking out the appropriate translations, and providing any values that are needed for formatting in a callback. Basic example (probably what EUI would use as a default): const translations = {
loadingOptions: `Loading options`,
alreadyAdded: value => <span><strong>{value}</strong> has already been added</span>,
addOption: value => <span>Hit <EuiCode>ENTER</EuiCode> to add <strong>{value}</strong> as a custom option</span>,
noOptions: `There aren’t any options available`,
allOptionsSelected: `You’ve selected all available options`,
}
// Then:
<EuiComboBox
{ ...otherProps }
translations={ translations } /> Cloud UI example using const translations = {
loadingOptions: <FormattedMessage
id='foo.loadingOptions'
defaultMessage='Loading options' />,
alreadyAdded: value => <FormattedMessage
id='foo.alreadyAdded'
defaultMessage='{option} has already been added'
values={{
option: <strong>{ value }</value>,
}} />,
addOption: value => <FormattedMessage
id='foo.addOption'
defaultMessage='Hit {key} to add {option} as a custom option'
values={{
key: <EuiCode>ENTER</EuiCode>, // Should intl this too, but this is a demo
option: <strong>{ value }</value>,
}} />,
noOptions: <FormattedMessage
id='foo.noOptions'
defaultMessage='There aren’t any options available' />,
allOptionsSelected: <FormattedMessage
id='foo.allOptionsSelected'
defaultMessage='You’ve selected all available options' />,
} |
Nice! I think this is the right pattern. Though I think we should change the prop name to something i18n-agnostic, like "messages" or "microcopy", since the prop is essentially about customizing the text in the component (uncoupled to internationalization). |
Ah yeah, good point. There's no reason at all to call it |
I noticed that |
Good point Rory. It seems like |
I'm actually wondering now if, in time, we might need an I'm just floating ideas, BTW, I haven't thought it through. |
Kibana wraps its toasts in an abstraction, which I think would be the right place to configure these messages. Encapsulated there, consumers would never need to know about them. We should probably do an audit of all of the places these messages would need to be defined before spitballing solutions, but it's possible that similar abstractions could serve the same purpose everywhere these messages are required. |
@cjcenizal can you link an example of how Kibana does it? |
It's a little convoluted:
If anyone is interested, here's where the interface is documented: https://github.com/elastic/kibana/blob/master/src/ui/public/notify/toasts/TOAST_NOTIFICATIONS.md |
Talked with @azasypkin about i18n+EUI, our plan is to create an @snide targeting 6.7, there's a translation effort happening around mid-January so we'll want our strings identified by then and initial implementation available for testing @timroes how much effort (one time vs. on-going) would it take to maintain & use a wrapping component in Kibana, considering our angular/react codebase. @pugnascotia same question as above, would this work for Cloud? |
@chandlerprall That sounds great. All of the newer Elasticsearch apps are written as standalone React apps with clear mounting points (e.g. Index Management), so your solution sounds like it would be pretty easy to implement for us. |
That should work from a Cloud POV. We already have a top-level point where we add context providers, so adding |
/cc @ppisljar as well, to make sure #738 (comment) works for the Kibana Apps team. |
our apps are not in react yet, but i guess the only difference for us is that we would need to be a bit more careful to actually pass EuiContext wrapper to every place we use react ? |
Yeah, only on every React -> DOM or React -> Angular "boundary". Technically we do this already with |
API and Usage proposal is up at #1404 for review. |
Closing this. We have the pieces in place for this. It's just the tokenization at this point, which would be better served by another issue. |
Since EUI is now providing controls that contain text (i.e. combo box), we need to think about how to allow for internationalisation. Cloud UI is already using react-intl heavily, but I don't think EUI should have any opinion over how the i18n is done.
I wondered if it might work to have an extra prop, e.g.
translations
, which is an object of all the required strings (or more precisely React nodes, to allow for custom formatting / content). The prop types would document the required keys and the default values.cc @cjcenizal
The text was updated successfully, but these errors were encountered: