[openstack-dev] [tripleo][ui] another i18n proposal for heat templates 'description' help strings

Peng Wu peng.e.wu at gmail.com
Wed Apr 12 09:06:31 UTC 2017


Hi Julie,

  Please see the comments in line.


On Mon, 2017-04-10 at 16:13 +0100, Julie Pichon wrote:
> Hi Peng,
> 
> I added some thoughts in-line, let me know what you think.
> 
> On 10 April 2017 at 08:10, Peng Wu <peng.e.wu at gmail.com> wrote:
> > Hi,
> > 
> >   In TripleO UI project users requested translation of the web UI.
> > But
> > some web UI strings are displayed from heat template files in
> > tripleo-
> > heat-templates project.
> > 
> >   In order to get translated templates displayed in tripleo-ui, we
> > propose another solution as follows, which needs to change code in
> > tripleo-heat-templates and tripleo-ui projects.
> > 
> >   I18n proposal for Heat templates 'description' help strings
> > 
> >   1. Update tripleo-heat-templates to generate the javascript files
> > to
> > include all translation strings, like "tripleo-heat-templates.js"
> > 
> >      a. Need to write python script to extract "title" and
> > "description" field from yaml files and generate "tripleo-heat-
> > templates.js" for react-intl usage in tripleo-ui
> 
> I think extracting the strings directly into js/json format may be
> not
> be a viable option, because it isn't a format supported by
> Zanata [1].
> 
> For tripleo-ui itself we use react-intl which expects json, and work
> with scripts to convert to/from pot and po (see [2]) which are fully
> supported by Zanata.
> 
> Or is the idea that we'd also generate pot/po as intermediary steps
> and
> only store json in the repo?
> 

I think we will just generate one javascript file which contains all
translatable strings, and copy the javascript file to tripleo-ui, and 
translations will only happens in tripleo-ui as other strings from
tripleo-ui project.

The generated javascript file is like:
const messages = defineMessages({
  root_template_description: {
    id: 'Base Resources Configuration',
    defaultMessage: 'Base Resources Configuration'
  }
},
...
);


> >      b. Use default message as message id or consider nodejs-i18n
> > for
> > tripleo-ui
> 
> I'm wary of considering a library change considering the amount of
> churn it would cause in the code base for all the existing strings,
> plus that would then make backports more difficult. It really needs
> to
> be considered carefully.
> 

To use nodejs-i18n is just a backup plan, from reply of react-intl we
may just use default message as message id only for translatable
strings from tripleo-heat-templates project.

> > 
> >   2. Update tripleo-ui to use "tripleo-heat-templates.js"
> > 
> >      a. Write some script to sync "tripleo-heat-templates.js" from
> > tripleo-heat-templates
> > 
> >      b. Call formatMessage function for "title" and "description"
> > field
> > with message id (use default message) and default message or
> > consider
> > nodejs-i18n for tripleo-ui
> > 
> >   Refer URL for message id: https://github.com/yahoo/react-intl/iss
> > ues/
> > 912
> 
> Could you explain a bit more the issue with the ids? I see us
> defining
> an id in every message [3] and this is how they are referenced in the
> locale json [4] (the mapping is not done by message, but by ID).
> 
> When it comes to the THT message, I think they all have a hierarchy
> that perhaps could be used as a key to map between the original
> string
> and the translation? Something along the lines of
> OS::TripleO::Services::Apache::ApacheMaxRequestWorkers::description,
> whichever form the API gives us at the moment.
> 

Actually I didn't find an message id like
"OS::TripleO::Services::Apache::ApacheMaxRequestWorkers::description"
when checking the tripleo-ui source code.

And I can't find "OS::TripleO::Services" in capabilities-map.yaml of
tripleo-heat-templates project.	

If both tripleo-heat-templates and tripleo-ui projects could generate
the same message id, it could be used.
But it seems only default message is sent to tripleo-ui project when I
am checking.

Feel free to comment it! Thanks!

Regards,
  Peng


> >   Please evaluate it, thanks!
> 
> Thank you!
> 
> Julie
> 
> [1] http://docs.zanata.org/en/release/user-guide/projects/project-typ
> es/#supported-types
> [2] https://github.com/openstack/tripleo-ui/blob/master/docs/translat
> ion.rst#extracting-messages-from-components
> [3] https://github.com/openstack/tripleo-ui/blob/master/src/js/compon
> ents/nodes/Nodes.js#L17
> [4] https://github.com/openstack/tripleo-ui/blob/master/i18n/locales/
> es.json#L3



More information about the OpenStack-dev mailing list