On Fri, Jun 26, 2020 at 4:06 PM James E. Blair <corvus@inaugust.com> wrote:

I think my biggest concern with this is how awkward the Translate
component is to use.  It looks like every string needs an identifier, so
what's currently:
     <Link> Summary </Link>

Turns in to:
     <Link> <Translate value='buildContainer.build.summary' /> </Link>

In python, with gettext, the change is more like:
     print("Summary")

to:
     print(_("Summary"))

This is not only less typing, but critically, the developer doesn't need
to create an identifier for the string (and ensure it's unique within
the relevant namespace).  This makes it easier for developers to perform
maintenance on code, and increases the likelihood of compliance with the
i18n standards (and therefore a higher rate of translatable strings).

Is there any kind of system like this for react?  It seems at the very
least, we should be able to do something like:

     <Link> <t> Summary </t> </Link>

and have that work like gettext.  Does something like that exist?

-Jim
 
All the examples I found used a namespace, but it turns out it is also possible to use regular strings, getting closer to what's familiar with gettext, see https://review.opendev.org/#/c/737290/6.
It should also be possible to create a function _ as a shortcut to the <Translate /> component, but developers would still need to differentiate "pure" text strings (translated with the _ function) from translatable strings passed as components' properties (which need to be translated with the I18n.t function).

It also turns out tripleo-ui implemented i18n in a comparable way (but with another library): https://blueprints.launchpad.net/tripleo/+spec/tripleo-ui-i18n-support-for-js and https://review.opendev.org/#/q/topic:bp/tripleo-ui-i18n-support-for-js+(status:open+OR+status:merged)
The good news is that Zanata integration and using the existing i18n-related Zuul jobs for this shouldn't be too hard, should we want to go this way.
 
_______________________________________________
Zuul-discuss mailing list
Zuul-discuss@lists.zuul-ci.org
http://lists.zuul-ci.org/cgi-bin/mailman/listinfo/zuul-discuss


--

Matthieu Huin

Senior Software Developer

Red Hat