<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
	<id>https://patrius.cnes.fr/index.php?action=history&amp;feed=atom&amp;title=User_Manual_4.16_Errors_management_and_internationalization</id>
	<title>User Manual 4.16 Errors management and internationalization - Historique des versions</title>
	<link rel="self" type="application/atom+xml" href="https://patrius.cnes.fr/index.php?action=history&amp;feed=atom&amp;title=User_Manual_4.16_Errors_management_and_internationalization"/>
	<link rel="alternate" type="text/html" href="https://patrius.cnes.fr/index.php?title=User_Manual_4.16_Errors_management_and_internationalization&amp;action=history"/>
	<updated>2026-04-06T11:26:41Z</updated>
	<subtitle>Historique des versions pour cette page sur le wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://patrius.cnes.fr/index.php?title=User_Manual_4.16_Errors_management_and_internationalization&amp;diff=3997&amp;oldid=prev</id>
		<title>Admin tsn : Page créée avec « == Introduction == === Scope === A locale is a set of 2 parameters, one to define the user’s language, the other one to define the country. A locale is used to identify a country, a language or a dialect.  The language parameter is composed by 2 lower cases whose list is defined by the [http://www.loc.gov/standards/iso639-2/php/code_list.php ISO 639-2 Langage Code List] [R1]. For instance, “fr” means French whereas “en” means English.   The country para... »</title>
		<link rel="alternate" type="text/html" href="https://patrius.cnes.fr/index.php?title=User_Manual_4.16_Errors_management_and_internationalization&amp;diff=3997&amp;oldid=prev"/>
		<updated>2025-04-23T09:32:35Z</updated>

		<summary type="html">&lt;p&gt;Page créée avec « == Introduction == === Scope === A locale is a set of 2 parameters, one to define the user’s language, the other one to define the country. A locale is used to identify a country, a language or a dialect.  The language parameter is composed by 2 lower cases whose list is defined by the [http://www.loc.gov/standards/iso639-2/php/code_list.php ISO 639-2 Langage Code List] [R1]. For instance, “fr” means French whereas “en” means English.   The country para... »&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Introduction ==&lt;br /&gt;
=== Scope ===&lt;br /&gt;
A locale is a set of 2 parameters, one to define the user’s language, the other one to define the country. A locale is used to identify a country, a language or a dialect.&lt;br /&gt;
&lt;br /&gt;
The language parameter is composed by 2 lower cases whose list is defined by the [http://www.loc.gov/standards/iso639-2/php/code_list.php ISO 639-2 Langage Code List] [R1]. For instance, “fr” means French whereas “en” means English. &lt;br /&gt;
&lt;br /&gt;
The country parameter is composed by 2 upper cases whose list is defined by the [http://www.iso.org/iso/fr/country_codes/iso_3166_code_lists/french_country_names_and_code_elements.htm ISO 3166 French Country Names and Code Elements] [R2]. France is designated by “FR”, Belgium by “BE” and United Kingdom by “GB”.&lt;br /&gt;
&lt;br /&gt;
The association of a language parameter and a country parameter leads to a full definition of all language varieties. As a result, the fr_FR locale points out French language spoken in France whereas the fr_BE locale points out French language spoken in Belgium.&lt;br /&gt;
&lt;br /&gt;
Here is a use case of  the Locale object :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
// French locale&lt;br /&gt;
Locale france = new Locale(&amp;quot;fr&amp;quot;, &amp;quot;FR&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// French locale language &lt;br /&gt;
Locale french = new Locale(&amp;quot;fr&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// Belgium locale &lt;br /&gt;
Locale belgium = new Locale(&amp;quot;fr&amp;quot;, &amp;quot;BE&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moreover, some locales are defined as constants of the class. This is the case for French language (Locale.FRENCH), French locale (Locale.FRENCH) or English language (Locale.ENGLISH).&lt;br /&gt;
&lt;br /&gt;
The second Java component i18n is the ResourceBundle. It is in charge of retrieving a given locale. However, the ResourceBundle is an abstract class, therefore a concrete implementation of the ResoureBundle, namely the PropertyResourceBundle, is used. This implementation is based on a basic file name, “properties”, and, for a given locale, it goes for the translation if it is available. To do that, it checks if a properties file, whose name is &amp;lt;basic file name&amp;gt;_&amp;lt;language code&amp;gt;_&amp;lt;country code&amp;gt;, exists.&lt;br /&gt;
&lt;br /&gt;
If necessary it goes for a translation that is more common, that is to say only based on the language and whose properties file would be named &amp;lt;basic file name&amp;gt;_&amp;lt;language code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If the need still arises, it goes for the basic file to retrieve a translation.&lt;br /&gt;
&lt;br /&gt;
For example, in the following code :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
ResourceBundle bundle = ResourceBundle.getBundle(&amp;quot;message&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the current locale (for example the default language of the operating system) is fr_FR, here is the order of the files research :&lt;br /&gt;
&lt;br /&gt;
3.1. message_fr_FR.propertie,&amp;lt;br&amp;gt;&lt;br /&gt;
3.2. message_fr.properties,&amp;lt;br&amp;gt;&lt;br /&gt;
3.3. message.properties.&lt;br /&gt;
&lt;br /&gt;
It is possible to get back a particular ResourceBundle by specifying explicitly the locale to be used :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
ResourceBundle bundle = ResourceBundle.getBundle(&amp;quot;message&amp;quot;, Locale.ENGLISH);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Afterwards, in order to get an internationalized message, for example a message associated to the key “HelloWorld” in the properties file, the method getString(String key) must be used :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
String message =  bundle.getString(&amp;quot;HelloWorld&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Javadoc ===&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
=== Useful Documents ===&lt;br /&gt;
&lt;br /&gt;
=== Package Overview ===&lt;br /&gt;
&lt;br /&gt;
== Features Description ==&lt;br /&gt;
=== Exception and internationalization ===&lt;br /&gt;
As indicated in the SRS document (requirements PBD-LOG_850), we should create an error message only when it is the only option i.e. Java basic errors  suit. In this case, it is mandatory to add a particular error message, the procedure is the following one :&lt;br /&gt;
&lt;br /&gt;
* Find a unique identifier (one key, see the following chapter for the definition rule) for the message and a short and relevant text,&lt;br /&gt;
* Modify the PatriusMessages class and add it to the enumeration, in US English which is the default language, e;g. FOO_MESSAGE(&amp;quot;foo message for testing purpose&amp;quot;) or BAR_MESSAGE(&amp;quot;another foo message for testing purpose {0} {1}&amp;quot;) with 2 expected arguments,&lt;br /&gt;
* Add this message to the translation files PatriusMessages_&amp;lt;language&amp;gt;.properties, one per language, in the directory …/src/main/resources/META-INF/localization, with the following form “key=text”. The text is translated in the required language, one has to be carful with the arguments location if there are some of them (they can be inverted).&lt;br /&gt;
&lt;br /&gt;
N.B. : For languages which use accents like French, each accented character has to be written with a specific coding. The list of the characters and their equivalent coding is available on the following web site : [http://www.utf8-chartable.de/ http://www.utf8-chartable.de/]&lt;br /&gt;
&lt;br /&gt;
If a class is necessary for a specific message type, it has to inherit from the one of the following java classes : Exception or RuntimeException.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class MyFutileException extends Exception implements ExceptionContextProvider {&lt;br /&gt;
   ...&lt;br /&gt;
   private ExceptionContext exceptionContext ; /** compulsory variable */&lt;br /&gt;
   ...&lt;br /&gt;
   MyFutileException(final Locale locale,final Object ... args) {&lt;br /&gt;
      exceptionContext.addMessage(locale,PatriusMessages.PDB_FUTILE_EXCEPTION,args)&lt;br /&gt;
   }&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this case, a unique identifier as well as the original text of the message and its translations are also needed in the translation files.&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
== Contents ==&lt;br /&gt;
=== Interfaces ===&lt;br /&gt;
&lt;br /&gt;
=== Classes ===&lt;/div&gt;</summary>
		<author><name>Admin tsn</name></author>
	</entry>
</feed>