[Apiman-user] APIMAN Internationalization question

Eric Wittmann eric.wittmann at redhat.com
Sat Dec 27 09:59:42 EST 2014


Hi qiyang, thanks for the question.  I'm CC'ing the apiman-user mailing 
list since I think the answer might be broadly helpful.  :)

There are various places where internationalization comes into play. 
You are asking specifically about the UI templates, so I'll address that 
first.  The UI templates do contain the "default" language strings, 
which in this case are english.  The UI is built on Errai/GWT, which 
comes with i18n support built in.  The way it works is that Errai will 
automatically translate the strings in the templates by using an 
appropriate JSON translation bundle file for the current locale (if one 
exists).  You can find the default bundle file here:

https://github.com/apiman/apiman/blob/master/manager/ui/war/src/main/java/io/apiman/manager/ui/client/local/messages.json

Because the defaults are *also* taken from the templates, I don't 
actually have any strings in the default bundle.  However, the way this 
works is very similar to java message bundles - there would be multiple 
messages.json files with different locales, such as 
"messages_en_US.json" or "messages_fr.json".  The framework will pick 
the right one at runtime based on the current browser locale.

The other interesting thing to note is that during the build, Errai will 
output a couple of generated bundle files that contain all of the 
strings that *should* be present in the bundle file.  This can be found 
here:

apiman/manager/ui/war/target/classes/.errai/errai-bundle-all.json

So we can take that file and copy it into src/main/java as mentioned 
above, and it could become the default bundle file.  Then copy it again 
and rename it as messages_en_US.json and it would be the correct US 
English bundle file, etc...

All of this should be working today, so creating a UI translation should 
be possible (with the caveat that we haven't actually tried it yet, so 
there may be some bugs).

Note that there are also places in the UI *other than the templates* 
where user-visible strings are used and must be translatable.  These 
strings are all located here:

https://github.com/apiman/apiman/blob/master/manager/ui/war/src/main/java/io/apiman/manager/ui/client/local/AppMessages.java

Adding a string in that form will allow Errai to discover it at build 
time and include it with the rest of the strings it finds in the templates.

Of course, there are also strings that are used on the server-side in 
both the API Manager and API Gateway that should also ideally be 
translated.  In those cases (all non-UI related strings) we use standard 
java message bundles.  :)

-Eric



On 12/26/2014 1:44 AM, qiyang at chinacloud.com.cn wrote:
> Hi, Eric
> I'm one of these chinese engineers who recently join in the APIMAN
> project. My nick name is 'qiyang' in IRC.
> I know that you are in vacation, but I got some question about the
> APIMAN, so I wrote this email.
> here is my question:
> I notice the text display in page almost write directly in the html
> file, such as
> <span class="description" data-i18n-key="page-description">
> Welcome to apiman, open source API management. Use this software to provide
> various APIs (Services) to your users (Applications) through a secure,
> scalable,
> and governed Gateway layer. API Management allows Service Developers to
> centralize
> control and analysis of their Services. It also provides a central
> locaton for
> Application Developers to find and consume available APIs.
> </span>
>
> Do you consider about the Internationalization? the "data-i18n-key="
> seem to reserve for Internationalization, but I can find any related
> file or code.
> If you plan to do this but you do not have enough time to catch up, you
> can tell me about your plan, I can help to realize the Internationalization.
> Looking forward to your reply!
>
> ------------------------------------------------------------------------
>
> cid:image003.jpg at 01CF84B4.15D5DA30
>
> *中电科华云信息技术有限公司*
>
> 姓名:漆杨部门:平台产品部
>
> 电话:028-65788632
>
> 地址:成都市高新区天府大道中段1268号天府软件园E3座8层
> 邮箱:qiyang at chinacloud.com.cn
>


More information about the Apiman-user mailing list