Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Babel » Finding the language of a translation
Finding the language of a translation [message #1840874] Tue, 27 April 2021 20:26 Go to next message
Andrew Johnson is currently offline Andrew JohnsonFriend
Messages: 205
Registered: July 2009
Senior Member
Is there a standard way of finding the language of a message string obtained from a Messages.java file or else Platform.getResourceString(bundle, n) for plugin type text?

The use case is for correctly tagging dynamically built HTML pages with lang= and hreflang= attributes. With a bit of care it is even possible to tag different parts of the page with different languages if that what the source text is like.

It's for Eclipse Memory Analyzer, though we don't have enough translated messages for it to be a real problem yet, but I'm curious as to the right way to do it.

There are queries written in Java, possibly including additional queries written by adopters, which could have message properties file including translated versions.
These queries are then combined into reports, defined in XML, with translations in plugin.properties. Reports can also call other reports. There are also so header, footer and navigation elements generated by MAT code, with text that also could be translated.

Now conceivably there could be differing amounts of translations available. You could have a query only available in English, a report available in English, but also translated into Portuguese and also translated into Brazilian Portuguese for the few messages were these differed. The translations could be supplied at different times, so the language codes can't be hard coded.

One way would be to convert each message back to a language by looking up all translated messages with different locales, and finding the most specific locale which matches. For Brazilian Portuguese that might give odd results if just some messages on a page were Brazilian Portuguese and the rest relied on a (correct) fallback to Portuguese messages. A screen reader might read Brazilian Portuguese in a man's voice and Brazilian accent and the remaining messages in a woman's voice and a European Portuguese accent even though all the text was correct Brazilian Portuguese. Perhaps messages could be duplicated between the two message files but that seems hard work.

Another way might be to have a special message for each message file:
lang=pt-br
or
lang=pt
which is only defined once most of the messages have been translated or are correct in the fall-back version. That would need to be marked as non-translatable so it wasn't defined too soon, but needs to be set by the translator when the page is done.

Also - what to do about default messages - how should they get a tag of English?
Re: Finding the language of a translation [message #1840923 is a reply to message #1840874] Wed, 28 April 2021 20:48 Go to previous messageGo to next message
Denis Roy is currently offline Denis RoyFriend
Messages: 484
Registered: October 2004
Location: Ottawa, Ontario, Canada
Senior Member

Hi Andrew,

I'm not sure how well this will answer your questions - but Babel does have pseudo translation packs. From the download page:
https://www.eclipse.org/babel/downloads.php

Babel Pseudo Translations
Babel Pseudo Translations are a very useful tool for globalization testing of Eclipse projects.

See the "Babel Pseudo Translations" Eclipse Corner Article for step-by-step instructions and examples describing what are the Babel Pseudo Translations, where to download them, how to install them, and how to launch Eclipse in Babel Pseudo Translations.

Eclipse developers can use the Babel Pseudo Translations to verify the translatability of their projects and make sure Eclipse excels in national language support.

Otherwise, I'm hoping Kit Lo can chime in.


Denis Roy
Eclipse Webmaster -- webmaster@eclipse.org
Re: Finding the language of a translation [message #1842774 is a reply to message #1840874] Thu, 01 July 2021 05:06 Go to previous message
Kit Lo is currently offline Kit LoFriend
Messages: 137
Registered: July 2009
Senior Member
Sorry, Andrew, I do not check the forum very often. Did you see your question until now.

Please take a look at the Eclipse locale specific files loading mechanism here:
https://help.eclipse.org/2021-06/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fproduct_def_nl.htm

Babel language packs are packaged as Eclipse NL fragments. Eclipse uses the current Java locale or system locale to search and fallback in the order described in the doc link above. For example, if the current locale is pt_BR, it will search the NL fragment for plugin_pt_BR.properties. If not found, it will fallback to plugin_pt.properties. If still not found, it will load the English plugin.properties in the host plugin.

The use case I usually see is that a user's system is set to a specific locale (for example, Brazilian Portuguese or Japanese). End users usually do not change their locale. They stay in a specific locale and expect to see all UI in that particular locale.

Your use case sounds like it's for a developer to display information in multiple languages for testing. One option I can think of is to programmatically changing the locale inside your application one by one and then load the messages in different languages. I never tried that before. But, give it a try. Good luck!

Regards,
Kit Lo
Eclipse Babel Project Lead
IBM Eclipse SDK (IES) Technical Lead and Release Manager
Previous Topic:Babel Language Packs R0.19.0 are now available!
Next Topic:Babel Language Packs R0.19.1 are now available!
Goto Forum:
  


Current Time: Wed Feb 05 04:45:30 GMT 2025

Powered by FUDForum. Page generated in 0.03926 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top