[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:
@@ -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"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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" }
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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" },
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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" } }
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user