0

I just want to create desktop application which have labels in two language. When I press "EN" button load English language labels otherwise Germany.

In web application I have .property file, it is possible to use property file in desktop applications.

Unihedron
  • 10,251
  • 13
  • 53
  • 66
Hayk Harutyunyan
  • 117
  • 1
  • 2
  • 17

2 Answers2

1

Just make like this, you need to have a properties file in each language and reload it on ResourceBundle.

package test;
Test.java
bundle_de.properties
bundle_en.properties

The main code.

package test;

import java.util.Locale;
import java.util.ResourceBundle;

public class Test {

    public static void main(String[] args) {
        ResourceBundle rb = ResourceBundle.getBundle("test.bundle", Locale.ENGLISH);
        System.out.println(rb.getString("wololo"));

        rb = ResourceBundle.getBundle("test.bundle", Locale.GERMAN);
        System.out.println(rb.getString("wololo"));
    }

}

Console output:

 Wololo in english
 Wololo in german
0

You need to use resource bundles for localization. Read this tutorial end to end

Vighanesh Gursale
  • 863
  • 4
  • 15
  • 30