Article View: es.comp.lenguajes.java
Article #590Re: Internacionalizaci�n
From: ElLlaneroSolitario
Date: Thu, 12 Apr 2007 22:46
Date: Thu, 12 Apr 2007 22:46
46 lines
2488 bytes
2488 bytes
En la clase principal tengo definidas estas dos variables:
public static Locale idioma;
public static ResourceBundle recurso;
El m�todo main lo hago as�:
public static void main(String args[]) {
if(args.length!=0){
if(args[0].compareTo("-en")==0)
idioma=new Locale("en","GB");
}
else{
idioma=Locale.getDefault();
}
recurso = ResourceBundle.getBundle("Gestion", idioma);
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new VentanaGestion().setVisible(true);
}
});
}
Y, por fin, para internacionalizar cada texto, lo hago con el asistente,
quedando, por ejemplo:
jLabel2.setText(recurso.getString("Seleccione_una_tabla"));
En el directorio donde est�n las clases (.class), est� el archivo con las
claves y los textos:
Gestion.properties
al cual le a�ad� una 'locale' para el ingl�s, con lo que en el directorio,
adem�s de las clases y del .properties, se encuentran:
Gestion_es_ES.properties
y
Gestion_en_GB.properties
Espero haberme explicado.
Saludos.
Technical Details
Message-ID:
<evmcqr$gk3$1@hefestos.uned.es>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!newsfeed.kamp.net!newsfeed.kamp.net!news.germany.com!news.belwue.de!kanaga.switch.ch!switch.ch!hefestos.uned.es!not-for-mailReferences:
<eseq1b$u5n$1@hefestos.uned.es> <1176399047.388064.225960@e65g2000hsc.googlegroups.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1116f3,8885ad7566426449 X-Google-Attributes: gid1116f3,public X-Google-Language: SPANISH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!newsfeed.kamp.net!newsfeed.kamp.net!news.germany.com!news.belwue.de!kanaga.switch.ch!switch.ch!hefestos.uned.es!not-for-mail From: "ElLlaneroSolitario" <javi-pas@telelineMenosEsto.es> Newsgroups: es.comp.lenguajes.java Subject: Re: Internacionalizaci�n Date: Fri, 13 Apr 2007 00:46:10 +0200 Organization: uned Lines: 48 Message-ID: <evmcqr$gk3$1@hefestos.uned.es> References: <eseq1b$u5n$1@hefestos.uned.es> <1176399047.388064.225960@e65g2000hsc.googlegroups.com> Reply-To: "ElLlaneroSolitario" <javi-pas@telelineMenosEsto.es> NNTP-Posting-Host: 90.red-80-37-213.staticip.rima-tde.net X-Trace: hefestos.uned.es 1176417947 17027 80.37.213.90 (12 Apr 2007 22:45:47 GMT) X-Complaints-To: admin.news@csi.uned.es NNTP-Posting-Date: Thu, 12 Apr 2007 22:45:47 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3028 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 X-RFC2646: Format=Flowed; Original X-Antivirus: avast! (VPS 000733-0, 11/04/2007), Outbound message X-Antivirus-Status: Clean