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

2017-05-15 Thread Peng Wu
On Wed, 2017-05-10 at 14:05 +0200, Jiri Tomasek wrote:
> I am probably a bit late to the discussion, but I think we're
> missing 
> quite important thing and that is the fact that TripleO UI is
> supposed 
> to use various plans (template sets) not strictly tripleo-heat-
> templates 
> repository contents. Tripleo-heat-templates repository is just a
> default 
> plan, but user can provide own changed files to the plan. Or create
> new 
> plan which is very different from what default tripleo-heat-
> templates 
> repository holds.
> 
> Also I am quite scared of keeping the GUI-specific file in sync with 
> tripleo-heat-templates contents.
> 
> IMHO a proper solution is introducing translations as part of 
> tripleo-heat-templates repository - template files hold the keys and 
> translations are held in a separate files in THT.
> 
> -- Jirka


Right, will consider to load the translations directly from
tripleo-heat-templates repository.

Maybe the generated javascript file still keep in THT,
and translated in THT.

Maybe we can name translations files in some hard-code file names
or in some config file, then load dynamically in tripleo-ui.

Regards,
  Peng


__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2017-05-14 Thread Peng Wu
Hi Florian,

On Tue, 2017-05-09 at 17:01 +0200, Florian Fuchs wrote:
> Thanks for the update Peng! A few comments:
> 
> 1. A minor thing: The file is missing the import for the
> defineMessages function, so that would have to be added here.

  Fixed.

> 2. The UI looks up messages by their object key, not the message id
> (random examples: [1]). The current naming would make that quite hard
> (description1, description2, descriptionN, ...). Ideally the key
> would
> be created using some reproducible conventions. For instance, the UI
> stores EnvironmentGroups by their title, Environments by their file
> path and Parameters by their name. If the message keys would reflect
> this structure, the UI could look up the objects dynamically, based
> on
> the naming conventions.
> 

  From react-intl reply, maybe we can use formatMessage like follow:

  

  URL: https://github.com/yahoo/react-intl/issues/609

> Two more things I noticed:
> 
> I count roughly 3400 occurrences of the word "description" in current
> tripleo-heat-templates. I'm not sure we need them all (your current
> example file only lists about 600, which would still be an acceptable
> number I guess), but if we do, we should probably think about some
> dynamic way to load messages in the UI and not put them all into one
> huge file.
> 

  I think we could improve it later or in next version.

Regards,
  Peng

> We need to handle cases where translatable t-h-t strings don't have a
> corresponding message object in the generated js file. That's
> probably
> not a big thing, but something we have to take care of.

__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2017-05-10 Thread Jiri Tomasek



On 9.5.2017 17:01, Florian Fuchs wrote:

On Mon, May 8, 2017 at 10:20 AM, Peng Wu  wrote:

Hi Julie,

   I generated one example javascript file containing the translatable
strings.
   URL: https://pwu.fedorapeople.org/openstack-i18n/tripleo/tripleo-heat
-templates.js

   And the code to generate the above file is in:
   https://pwu.fedorapeople.org/openstack-i18n/tripleo/

   The generated file need to be copied to tripleo-ui project, and
translate as other javascript files.

   Please review it, thanks!

Thanks for the update Peng! A few comments:

1. A minor thing: The file is missing the import for the
defineMessages function, so that would have to be added here.
2. The UI looks up messages by their object key, not the message id
(random examples: [1]). The current naming would make that quite hard
(description1, description2, descriptionN, ...). Ideally the key would
be created using some reproducible conventions. For instance, the UI
stores EnvironmentGroups by their title, Environments by their file
path and Parameters by their name. If the message keys would reflect
this structure, the UI could look up the objects dynamically, based on
the naming conventions.

Two more things I noticed:

I count roughly 3400 occurrences of the word "description" in current
tripleo-heat-templates. I'm not sure we need them all (your current
example file only lists about 600, which would still be an acceptable
number I guess), but if we do, we should probably think about some
dynamic way to load messages in the UI and not put them all into one
huge file.

We need to handle cases where translatable t-h-t strings don't have a
corresponding message object in the generated js file. That's probably
not a big thing, but something we have to take care of.

[1] 
https://github.com/openstack/tripleo-ui/blob/master/src/js/components/deployment/DeploymentDetail.js#L106
  
https://github.com/openstack/tripleo-ui/blob/master/src/js/components/deployment/DeploymentDetail.js#L59

__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


I am probably a bit late to the discussion, but I think we're missing 
quite important thing and that is the fact that TripleO UI is supposed 
to use various plans (template sets) not strictly tripleo-heat-templates 
repository contents. Tripleo-heat-templates repository is just a default 
plan, but user can provide own changed files to the plan. Or create new 
plan which is very different from what default tripleo-heat-templates 
repository holds.


Also I am quite scared of keeping the GUI-specific file in sync with 
tripleo-heat-templates contents.


IMHO a proper solution is introducing translations as part of 
tripleo-heat-templates repository - template files hold the keys and 
translations are held in a separate files in THT.


-- Jirka

__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2017-05-09 Thread Florian Fuchs
On Mon, May 8, 2017 at 10:20 AM, Peng Wu  wrote:
> Hi Julie,
>
>   I generated one example javascript file containing the translatable
> strings.
>   URL: https://pwu.fedorapeople.org/openstack-i18n/tripleo/tripleo-heat
> -templates.js
>
>   And the code to generate the above file is in:
>   https://pwu.fedorapeople.org/openstack-i18n/tripleo/
>
>   The generated file need to be copied to tripleo-ui project, and
> translate as other javascript files.
>
>   Please review it, thanks!

Thanks for the update Peng! A few comments:

1. A minor thing: The file is missing the import for the
defineMessages function, so that would have to be added here.
2. The UI looks up messages by their object key, not the message id
(random examples: [1]). The current naming would make that quite hard
(description1, description2, descriptionN, ...). Ideally the key would
be created using some reproducible conventions. For instance, the UI
stores EnvironmentGroups by their title, Environments by their file
path and Parameters by their name. If the message keys would reflect
this structure, the UI could look up the objects dynamically, based on
the naming conventions.

Two more things I noticed:

I count roughly 3400 occurrences of the word "description" in current
tripleo-heat-templates. I'm not sure we need them all (your current
example file only lists about 600, which would still be an acceptable
number I guess), but if we do, we should probably think about some
dynamic way to load messages in the UI and not put them all into one
huge file.

We need to handle cases where translatable t-h-t strings don't have a
corresponding message object in the generated js file. That's probably
not a big thing, but something we have to take care of.

[1] 
https://github.com/openstack/tripleo-ui/blob/master/src/js/components/deployment/DeploymentDetail.js#L106
 
https://github.com/openstack/tripleo-ui/blob/master/src/js/components/deployment/DeploymentDetail.js#L59

__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2017-05-08 Thread Peng Wu
Hi Julie,

  I generated one example javascript file containing the translatable
strings.
  URL: https://pwu.fedorapeople.org/openstack-i18n/tripleo/tripleo-heat
-templates.js

  And the code to generate the above file is in:
  https://pwu.fedorapeople.org/openstack-i18n/tripleo/

  The generated file need to be copied to tripleo-ui project, and
translate as other javascript files.

  Please review it, thanks!

Regards,
  Peng


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  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?
> 
> >  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.
> 
> > 
> >   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.
> 
> >   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

__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2017-04-12 Thread Peng Wu
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  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

__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2017-04-10 Thread Julie Pichon
Hi Peng,

I added some thoughts in-line, let me know what you think.

On 10 April 2017 at 08:10, Peng Wu  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?

>  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.

>
>   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/issues/
> 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.

>   Please evaluate it, thanks!

Thank you!

Julie

[1] 
http://docs.zanata.org/en/release/user-guide/projects/project-types/#supported-types
[2] 
https://github.com/openstack/tripleo-ui/blob/master/docs/translation.rst#extracting-messages-from-components
[3] 
https://github.com/openstack/tripleo-ui/blob/master/src/js/components/nodes/Nodes.js#L17
[4] https://github.com/openstack/tripleo-ui/blob/master/i18n/locales/es.json#L3

__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev