Java resource bundle: Difference between revisions

Content deleted Content added
Tag: section blanking
Bender the Bot (talk | contribs)
 
(17 intermediate revisions by 14 users not shown)
Line 1:
{{Short description|Computer language data file}}
A resource bundle is a [[Java (software platform)|Java]] [[.properties]] file that contains [[locale]]-specific data.<ref>[http://java.sun.com/developer/technicalArticles/Intl/ResourceBundles/ O'Conner, B. ''Java Internationalization: Localization with ResourceBundles'', Sun Developer Network.]</ref> It is a way of internationalising a Java application by making the code locale-independent.
{{also|Resource (Java)}}
 
A resource bundle is a [[Java (software platform)|Java]] [[.properties]] file that contains [[Locale (computer software)|locale]]-specific data.<ref>[{{Cite web|first=John|last=O'Conner|archive-date=2007-01-03|title=Java Internationalization: Localization with ResourceBundles|url=http://java.sun.com/developer/technicalArticles/Intl/ResourceBundles/ O'Conner, B|archive-url=https://web. ''Java Internationalizationarchive.org/web/20070103035343/http: Localization with //java.sun.com/developer/technicalArticles/Intl/ResourceBundles'', /|access-date=2020-11-16|website=Sun Developer Network.]}}</ref> It is a way of internationalising a Java application by making the code locale-independent.
== Content of a resource bundle ==
Resource bundles are essentially text files. The most common type of content in a resource bundle is a list of strings. Each string has a “key” to identify it, which is the same in all the different resource bundles. When writing the code for the application, only the key is mentioned (this is why we say that the code is locale-independent). Using the methods provided in the Java [[API]] for the ResourceBundle class,<ref>[http://java.sun.com/j2se/1.5.0/docs/api/ Java API ResourceBundle Class]</ref> we can access the string (i.e. the "value") associated with the key. Depending on which locale the application is handling, it will call the adequate resource bundle at [[Run time (computing)|runtime]].<ref>Esselink, B. ''A Practical Guide to Software Localisation'', John Benjamins Publishing (1998).</ref>
 
For instance, our resource bundle for the UK English locale can contain “firstKey = Localisation” and our US English one can contain “firstKey = Localization”. We will refer only to “firstKey” in the code and, according to the current locale settings, the application will use either “Localization” or “Localisation”.
 
== Benefits of using resource bundles ==
Line 10 ⟶ 7:
 
== Translating a resource bundle ==
Some [[CATComputer-assisted toolstranslation|CAT]] tools like [[OmegaT]], OmegaT+,<ref>[httphttps://omegatplus.sourceforge.net/ OmegaT+]</ref> [http://www.maxprograms.com/products/swordfish.html[Swordfish Translation Editor|Swordfish]] or Sun's [[Open language tools]] can specifically handle resource bundles. In addition to these, translators can use any [[text editor]] to create new resource bundles or to modify existing ones.
 
== ContentTools ofto acreate resource bundlebundles ==
The [http://www.tmasoft.de/MessageCompiler/index.html Message Compiler] <ref>[http://www.tmasoft.de/MessageCompiler/index.html Message Compiler]</ref> is a tool to generate resource bundle files from a single source file containing localized text definitions in different languages. The Message Compiler creates also constant definitions for the keys used to access the localized texts with the methods of the [[Java (programming language)|Java]] class [http://docs.oracle.com/javase/6/docs/api/java/util/ResourceBundle.html?is-external=true ResourceBundle (6)], [https://docs.oracle.com/javase/7/docs/api/java/util/ResourceBundle.html ResourceBundle (7)] and [[HTML]] documentation pages for each language.
 
== See also ==
[http://www.maxprograms.com/products/javapm.html JavaPM] is a free cross-platform utility that that assists software developers in the localization of Java projects. JavaPM converts Java .properties files to XLIFF 1.2 format, allowing their localization using most modern translation environments. Once the [[XLIFF]] files have been translated, JavaPM inserts the translations into the Java project, creating new .properties files or updating existing ones as necessary.
*[[Bundled software]]
 
== References ==
Line 18 ⟶ 19:
 
{{DEFAULTSORT:Java Resource Bundle}}
[[Category:Java (programming language)]]