tiagomac
tiagomac

Reputation: 481

how to format i18n files?

i got three files for internationalization: messages_es.properties, messages_en.properties and messages_pt.properties, those files follow the rule:

message1=value
message2=value2

and it's values changes according the file. example:

messages_en.properties:
hello=welcome
messages_pt.properties:
hello=bem vindo

the problem is, along the project construction those files becames inconsistent, like, lines that exists in one file doesn't exist on the others, the lines are not ordened in these files... i want to know if there is some way to easy rearrange and format those i18n files so the lines that exists in one file and don't exists in the other should be copied and the lines be ordered equals?

Upvotes: 1

Views: 3485

Answers (5)

Paweł Dyda
Paweł Dyda

Reputation: 18662

The problem you are facing is invalid Localization process. It has nothing to do with properties files and it is likely that you shouldn't even compare these files now (that is until you fix the process).
To compare properties files, you can use very simple trick: sort each one of them and use standard diff tool to show differences. Sure, you'll miss the comments and logical arrangement in the English file, but at least you can see what's going on. That could be done, but it is a lot of manual work.

Instead of manually fix the files, you should fix the broken process. The successful localization process is basically similar to this one:

  1. Once English file is modified, send the English file for translation. By that I mean all the translations should be based on English file and the localization files should be recreated (stay tuned).
  2. Use Translation Memory to fill up the translations you already have. This could be done by your translation service provider or yourself if you really know how to do it (guess what? it is difficult).
  3. Have the translators translate strings that are missing.
  4. Put localized file back.
  5. Before releasing the software to public have somebody to walk the Linguistic Reviewer through the UI and correct mistranslations.

I intentionally skipped few steps (like localization testing, using pseudo-translations and searching for i18n defects, etc.), but if you use this kind of process, your properties files should always be in sync.
And now your question could be reduced to the one that was already asked (and answered): Managing the localization of Java properties files.

Upvotes: 0

Joop Eggen
Joop Eggen

Reputation: 109613

The NetBeans IDE has a properties editor across languages, displaying them side-by-side in a matrix. Similarly there are stand-alone editors that allow to do this. One would assume that such an editor would keep the source text synchronized and in one consistent layout.

First go looking for a translator's editor that can maintain a fixed layout. A format like gettext (.po/.pot) which is similar to .properties might be a better choice, depending on the tool.

For more than three languages it would make sense to use a source format more directed at translators, like the XML format xliff (though .properties are well known). And generate from this source (via XSLT perhaps) the several .properties files, or even ListResourceBundles.

The effort for i18n should not stop at providing a list of phrases to translate, but some info where needed (disambiguating note), and maybe even a glossary for a consistent use of the same term. The text presented to the user is a very significant of the products quality and appeal. Using different synonyms may make the user-interface fuzzy, needlessly unclear, tangled.

Upvotes: 0

laune
laune

Reputation: 31300

Look at java.util.PropertyResourceBundle. It is a convenience class for reading a property file and you can obtain a Set<String> of the keys. This should help to compare the contents of several resource files.

But I think that a better approach is to maintain the n languages in a single file, e.g., using XML and to generate the resource files from a single source.

<entry>
   <key>somekey</key>
   <value lang="en">good bye</value>
   <value lang="es">hasta luego</value>
</entry>

Upvotes: -1

Yes, the messages should usually appear in each file, unless there's a default message for some key that doesn't need translating (perhaps technical terms). Different IDEs have different support for managing message files.

As far as ordering the messages, there's no technical need to do so, but it can help the human maintainers. Any text-editor's sort routine will work just fine.

Upvotes: 0

Leandro Carracedo
Leandro Carracedo

Reputation: 7355

Interesting question, you are dealing with text files so there are a lot of possible options to manage this situation but depends on your scenario (source control, ide, etc).

If your are using Eclipse check: http://marketplace.eclipse.org/content/eclipse-resourcebundle-editor

And for IntelliJ: https://www.jetbrains.com/idea/features/i18n_support.html

Upvotes: 2

Related Questions