[BAEL-1536] A Guide to the Resource Bundle (#3602)

* [BAEL-1536] A Guide to the Resource Bundle

The essential code for the article

* [BAEL-1536] A Guide to the Resource Bundle #2

The essential code for the article after the first article review.

* [BAEL-1536] A Guide to the Resource Bundle #3

Essential changes after the second review.

* [BAEL-1536] A Guide to the Resource Bundle #4

Essential changes after the second review:
- Doubles to BigDecimals
This commit is contained in:
Patryk
2018-02-22 21:45:27 +01:00
committed by pauljervis
parent d172168ace
commit 378cae0821
9 changed files with 172 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
package com.baeldung.resourcebundle;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
public class ExampleControl extends ResourceBundle.Control {
@Override
public List<Locale> getCandidateLocales(String s, Locale locale) {
return Arrays.asList(new Locale("pl", "PL"));
}
}

View File

@@ -0,0 +1,14 @@
package com.baeldung.resourcebundle;
import java.util.ListResourceBundle;
public class ExampleResource extends ListResourceBundle {
@Override
protected Object[][] getContents() {
return new Object[][] {
{ "greeting", "hello" }
};
}
}

View File

@@ -0,0 +1,15 @@
package com.baeldung.resourcebundle;
import java.util.ListResourceBundle;
public class ExampleResource_pl extends ListResourceBundle {
@Override
protected Object[][] getContents() {
return new Object[][] {
{ "greeting", "cześć" },
{ "language", "polish" },
};
}
}

View File

@@ -0,0 +1,17 @@
package com.baeldung.resourcebundle;
import java.math.BigDecimal;
import java.util.ListResourceBundle;
public class ExampleResource_pl_PL extends ListResourceBundle {
@Override
protected Object[][] getContents() {
return new Object[][] {
{ "currency", "polish zloty" },
{ "toUsdRate", new BigDecimal("3.401") },
{ "cities", new String[] { "Warsaw", "Cracow" } }
};
}
}