Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 92 → Rev 93

/sun/xmleditor/trunk/src/internationalization/Internationalization.java
1,64 → 1,122
/*
* Created on Jun 18, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package src.internationalization;
 
/** This file contains the Internationalization class.
*
* @version $Revision: 1.0 $
*
* Last modification: $Date: 2003/06/20 09:45:00 $
*/
 
import java.util.Locale;
import java.util.ResourceBundle;
import java.text.DateFormat;
import java.util.ResourceBundle;
 
 
/**
* @author swalkenh
/** This class provides methodes for internationalization.
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*
* status: first try
* The internationalization of the program is made by using
* a <code>ResourceBundle</code>-Object and its method
* <code>getString()</code> with a code-word which leads
* to a String of a specified language. An example can be
* seen in the testing output in method <code>localize</code>.
*
* The selection of the language must return a Language Code,
* that is a String, eg. "en" for the English language, which
* leds to the selection of the file named "Texts_en.properties".
* List of current legal Strings of this project: en English
* de German
* You can add a new language by editing a file named
* "Texts_<language code>.properties.
* Heres a link for proper language codes:
* <a href ="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt">
* <code>http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt</code></a>
*
* @see java.util.Locale
* @see java.util.ResourceBundle
*
* status: first try
*/
public class Internationalization {
 
public static void main(String[] args) {
Internationalization i = new Internationalization();
}
private String propertiesPath = "src.internationalization.Texts";
private ResourceBundle texts;
 
/** The main method makes a new instance of Internationalization.
*
* @param args parameter
*
* @author Sascha Walkenhorst
*
* Last Revision: 20-Jun-2003
*/
public static void main(String[] args) {
Internationalization i = new Internationalization();
}
 
public Internationalization() {
localizeNew();
}
 
/** This constructor ...
*
* @author Sascha Walkenhorst
*
* Last Revision: 20-Jun-2003
*/
public Internationalization() {
localizeNew();
available();
}
 
public ResourceBundle localizeNew() {
Locale loc = new Locale("en", "");
ResourceBundle texts = ResourceBundle.getBundle("src.internationalization.Texts", loc);
 
//Testausgabe
System.out.println(texts.getString("thisProperties"));
return texts;
}
/** This method makes a default <code>ResourceBundle</code>, the language is English.
*
* @return The ResourceBundle.
*
* @author Sascha Walkenhorst
*
* Last Revision: 20-Jun-2003
*/
public ResourceBundle localizeNew() {
Locale loc = new Locale("en", "");
texts = ResourceBundle.getBundle(propertiesPath, loc);
 
//testing output
System.out.println("thisProperties: " + texts.getString("thisProperties"));
return texts;
}
public ResourceBundle localize(String language) {
Locale loc = new Locale(language, "");
ResourceBundle texts = ResourceBundle.getBundle("src.internationalization.Texts", loc);
//Testausgabe
System.out.println(texts.getString("thisProperties"));
return texts;
}
public void available() {
Locale list[] = DateFormat.getAvailableLocales();
for (int i = 0; i < list.length; i++) {
System.out.println(list[i].toString() + ": " + list[i].getDisplayName());
}
}
/** This method makes a <code>ResourceBundle</code> of the given language.
*
* @param language The language code.
*
* @return The ResourceBundle.
*
* @author Sascha Walkenhorst
*
* Last Revision: 20-Jun-2003
*/
public ResourceBundle localize(String language) {
Locale loc = new Locale(language, "");
texts = ResourceBundle.getBundle(propertiesPath, loc);
//testing output
System.out.println("thisProperties: " + texts.getString("thisProperties"));
return texts;
}
/** This method shows the available language and country codes.
*
* @author Sascha Walkenhorst
*
* Last Revision: 20-Jun-2003
*/
public void available() {
Locale list[] = DateFormat.getAvailableLocales();
for (int i = 0; i < list.length; i++) {
System.out.println(list[i].toString() + ": " + list[i].getDisplayName());
}
}
}
/sun/xmleditor/trunk/src/internationalization/Texts_de.properties
2,7 → 2,7
 
title = XML Editor
menuFile = Datei
menuItemOpen = Oeffne Datei
menuItemOpen = Öffne Datei
menuItemExit = Ende
 
quitConfirmationQuit = Ende