• Aucun résultat trouvé

java.util.ResourceBundle

N/A
N/A
Protected

Academic year: 2022

Partager "java.util.ResourceBundle "

Copied!
9
0
0

Texte intégral

(1)

Internationalisation des applications Java

Ahcène Bounceur

(2)

java.util.ResourceBundle

 Resource bundles contain locale-specific objects.

 This allows you to write programs that can:

 be easily localized, or translated, into different languages

 handle multiple locales at once

 be easily modified later to support even

more locales

(3)

java.util.ListResourceBundle

ListResourceBundle is an abstract subclass of ResourceBundle that

manages resources for a locale in a

convenient and easy to use list.

(4)

MesMessages.java /défaut MesMessages_fr.java /français MesMessages_en.java /anglais

MesMessages_fr_FR.java MesMessages_fr_BE.java MesMessages_fr_CA.java

(5)

import java.util.*;

public class MesMessages extends ListResourceBundle {

public Object[][] getContents() { return contents;

}

static final Object[][] contents = { // LOCALIZE THIS

{"valider", "Valider"}, {"effacer", "Effacer"}, {"surnom", "* Surnom : "},

{"passe", "* Mot de passe : "}

// END OF MATERIAL TO LOCALIZE };

}

(6)

import java.util.*;

public class MesMessages_fr extends ListResourceBundle {

public Object[][] getContents() { return contents;

}

static final Object[][] contents = { // LOCALIZE THIS

{"valider", "Valider"}, {"effacer", "Effacer"}, {"surnom", "* Surnom : "},

{"passe", "* Mot de passe : "}

// END OF MATERIAL TO LOCALIZE };

}

(7)

import java.util.*;

public class MesMessages_en extends ListResourceBundle {

public Object[][] getContents() { return contents;

}

static final Object[][] contents = { // LOCALIZE THIS

{"valider", "Enter"}, {"effacer", "Clear"},

{"surnom", "* Nickname: "}, {"passe", "* Password: "}

// END OF MATERIAL TO LOCALIZE };

}

(8)

java.util.Locale

A Locale object represents a specific geographical, political, or cultural region.

An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user.

The language argument is a valid ISO Language

Code.

(9)

Locale maLocale = Locale.getDefault();

if ( langue.equals("en") ) {

maLocale = new Locale("en","GB");

}

else if ( langue.equals("fr") ) {

maLocale = new Locale("fr","FR");

}

Locale.setDefault(maLocale);

ResourceBundle mesMessages =

ResourceBundle.getBundle("MesMessages", maLocale);

System.out.println( mesMessages.getString("surnom") );

Références

Documents relatifs

N0 alternatives from which to choose. And if something is infinitely divisible, then the operation of halving it or halving some part of it can be performed infinitely often.

The distinction between thinking and reasoning will allow us to apply a structural equivalent of Ludwig Wittgenstein’s Private Language Argument to the domain of mind and

Some of these factors were already in the literature and some were added by the researcher i.e., whether the words are content or function words, the length of the

This last step does NOT require that all indicator be converted - best if only a small percent need to be reacted to make the change visible.. Note the

coclosure to give a construction of the associated cosheaf of an arbitrary precosheaf on a complete metric space0. To summarize, the category of cosheaves on an

The dual locale Fn B o f a seminormed space B in the category o f sheaves on X is a compact, completely regular locale.. The proof of this assertion is similar to

We define a partition of the set of integers k in the range [1, m−1] prime to m into two or three subsets, where one subset consists of those integers k which are < m/2,

After the presentation of the Data Gardens technical platform itself (in section 2), the paper will be organized by crossing three axis: the first axis corresponds to