A request for guidelines around translation keys in UI


#1

I’d like to get clarifications on the correct way to work in the frontend code with translation keys, right now
it seems there’s a mix of different styles of work.

Examples:
A. manageiq/app/presenters/menu/default_menu.rb has the following 2 different ways for strings:
N_(‘Providers’)
ui_lookup(:tables => ‘ontap_storage_system’)
which one of the above is correct? what is N_ ?

B. en.yml has a “model” section and also a “table” section, some ui_lookup calls are working with :tables key and some with :model key, some keys appear in both sections (for example Infrastructure Provider) - why, and which one should be used?

C. .po files - some information is there as well in addition to en.yml - what should go there? how stuff from that file should be referenced?

Please clarify the above. Thank you!


#2

@dclarizio @martin_povolny @hkataria please advise


#3

(‘foo’) means "translate foo"
N
(‘foo’) means “do not translate foo” but the string is captured by gettext rake task when building the catalogs

In menu we load the definition only once and then render the menu multiple times, potentially in different locales. So we need N_(‘foo’) so that strings get into the catalog but are not translated until render time.

See e.g. here: https://github.com/mutoh/gettext


#4

@marigold2048 Can we document this in the developer guides?


#5

Thanks @martinpovolny.
What about the “ui_lookup” call? When that should be used?
As I said, most of the files are really a mix of N_ , _ and ui_lookup with 2 different keys, and it will really help to get a clear guideline what to do looking forward


#6

@chessbyte, some more info and guidelines are needed for this topic


#7

@abonas: We are using gettext. There’s a nice reference here http://www.rubydoc.info/gems/gettext/ and there are tons of articles and resources such as http://www.gnu.org/software/gettext/manual/gettext.html#Programmers

How ever, you are right that we need more docs for our developers. I see 2 needs:

  1. A simple getting started with most common patterns including project specific stuff such as ui_lookup.
  2. A detailed document on how to deal with specific situations

I am going to prepare that.


Translations in Angular controllers and related code
#8

@abonas: We are working on i18n guidelines for developers here: https://github.com/ManageIQ/manageiq/issues/3775
You are welcome to comment there.


#9

thanks @martinpovolny !
cc @zeari please review