Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e7bc1a1

Browse files
1
1 parent 9da234f commit e7bc1a1

13 files changed

+103
-0
lines changed
Binary file not shown.
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>ResourceBundleDemo</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Greeting = Hi, how are you?
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Greeting = Salut comment ca va?
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import java.util.Locale;
2+
import java.util.ResourceBundle;
3+
import java.util.Scanner;
4+
5+
/**
6+
* If Application supports US Country and English language, then read
7+
* message from MessageBundle_en_US.properties file.
8+
*
9+
* If Application supports France country and French language, then
10+
* read message from MessageBundle_fr_FR.properties file.
11+
*/
12+
public class InternationalizationDemo
13+
{
14+
15+
public static void main(String[] args)
16+
{
17+
Scanner sc = new Scanner(System.in);
18+
19+
System.out.println("Enter Language code:");
20+
String languageCode = sc.next();
21+
22+
System.out.println("Enter Country code:");
23+
String countryCode = sc.next();
24+
25+
sc.close();
26+
27+
if (countryCode.equals("US") && languageCode.equals("en"))
28+
{
29+
/*
30+
* Gets a resource bundle using the specified base name
31+
* and locale
32+
*
33+
* Parameters:
34+
*
35+
* baseName - the base name of the resource bundle, a
36+
* fully qualified class name
37+
*
38+
* locale - the locale for which a resource bundle is
39+
* desired
40+
*
41+
* Returns:
42+
*
43+
* a resource bundle for the given base name and locale
44+
*
45+
*/
46+
ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle", Locale.US);
47+
48+
System.out.println("Message in " + Locale.US + " = " + bundle.getString("Greeting"));
49+
}
50+
else if (countryCode.equals("FR") && languageCode.equals("fr"))
51+
{
52+
ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle",Locale.US);
53+
Locale.setDefault(new Locale("fr", "FR"));
54+
55+
bundle = ResourceBundle.getBundle("MessageBundle");
56+
System.out.println("Message in " + Locale.getDefault() + " = " + bundle.getString("Greeting"));
57+
}
58+
else
59+
{
60+
System.out.println( "Please enter proper countryCode and languageCode.");
61+
}
62+
63+
}
64+
65+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Greeting = Hi, how are you?

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /