Ian
01/08/2020, 4:00 PMvar greeting = i18n.__('Hello');
and stops there as localization is "solved" 😛gman
01/08/2020, 4:02 PMgman
01/08/2020, 4:16 PMvar greeting = i18n.__('Hello');
sets off warning signals to me as it seems to suggest that 'Hello' will translate the same eveywhere it's used. That's not my experience so I'd expect var greeting = i18n.__(I81N_GREETING_ID_24);
given that some other place in the code will may also need 'Hello' but it will be a different 'Hello'cauli
01/09/2020, 9:03 AMi18n.__('Hello')
suggests to me that the strategy here is the "`gettext`" way in which the translations are extracted from the codebase then replaced in runtime, and key of a translation is a original string in the en
version of it.cauli
01/09/2020, 9:06 AMusing graphql to query for each bit of text
. You should have files that consolidate all translations for a locale for your app/system and then fetch them all at once (the most appropriate translations file), depending on the user's locale.Ian
01/09/2020, 4:06 PMi18n.__('Hello')
was just a reference to the gettext
approach, which I've run into most frequently. I'm looking for more interesting approaches.
the full approach we're using is Contentful -> Graphql query to get all our text -> it's loaded into the cache -> react hooks that query the graphql cache at the component level to get specific text, looks kind of like const text = useText('section.heading.hello')