1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
package params;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import vue.MessageErreur;
public class Messages {
private static final String BUNDLE_NAME = "lang.lang_"+ConfigParams.read("language");//$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
/**
* Renvoit le texte correspondant a l'identifiant dans le fichier de langue courant
* @param key Identifiant du texte a chercher dans le fichier de langue courant
* @return Texte correspondant a l'identifiant dans le fichier de langue courant
*/
public static String get(String key) {
try {
String msg = RESOURCE_BUNDLE.getString(key); // c'est la ligne 28 declarée par la console
// Remplacement des vraiables internes
msg = msg.replaceAll("#dev1", VarInternes.read("dev1"));
msg = msg.replaceAll("#dev2", VarInternes.read("dev2"));
msg = msg.replaceAll("#version", VarInternes.read("version"));
msg = msg.replaceAll("#soft", VarInternes.read("soft"));
return msg;
} catch (MissingResourceException e) {
MessageErreur.show("Missing Ressource Bundle !", "Missing Ressource");
return '!' + key + '!';
}
}
/**
* Renvoit le texte correspondant a l'identifiant dans le fichier de langue 'lang'
* @param lang Chaine de caracteres correspondant a un fichier de langue specifique
* @param key Identifiant du texte a chercher dans le fichier de langue 'lang'
* @return Texte correspondant a l'identifiant dans le fichier de langue 'lang'
*/
public static String get(String lang, String key) {
final String OTHER_BUNDLE_NAME = "lang.lang_"+lang;
final ResourceBundle OTHER_RESOURCE_BUNDLE = ResourceBundle.getBundle(OTHER_BUNDLE_NAME);
try {
return OTHER_RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
MessageErreur.show("Missing Ressource Bundle !", "Ressource manquante");
return '!' + key + '!';
}
}
} |
Partager