Code example for Locale

Methods: setDefault

0
        assertEquals("a ore 9. un piede", TextFactory.getText(MY_POSITION, EAST_1FT, 180));
        assertEquals("a ore 12. 0 piedi", TextFactory.getText(MY_POSITION, MY_POSITION, 0));
    } 
 
    public static void testGetTextSv() { 
        setLocale(new Locale("sv", "SE"), true);
        assertEquals("Klockan ett. 6 kilometer", TextFactory.getText(MY_POSITION, NORTH_6100M, 330));
        assertEquals("Klockan 9. 1,6 kilometer", TextFactory.getText(MY_POSITION, WEST_1MILE, 0));
        assertEquals("Klockan 6. en kilometer", TextFactory.getText(MY_POSITION, SOUTH_1020M, 0));
        assertEquals("Klockan 3. 120 meter", TextFactory.getText(MY_POSITION, EAST_123M, 0));
        assertEquals("Klockan 11. 34 meter", TextFactory.getText(MY_POSITION, WEST_34M, 290));
        assertEquals("Klockan 9. en meter", TextFactory.getText(MY_POSITION, EAST_1M, 180));
        assertEquals("Klockan 12. 0 meter", TextFactory.getText(MY_POSITION, MY_POSITION, 0));
 
        setLocale(new Locale("sv", "SE"), false);
        assertEquals("Klockan ett. 4 engelsk mil", TextFactory.getText(MY_POSITION, NORTH_6100M, 330));
        assertEquals("Klockan 9. en engelsk mil", TextFactory.getText(MY_POSITION, WEST_1MILE, 0));
        assertEquals("Klockan 6. 0,6 engelsk mil", TextFactory.getText(MY_POSITION, SOUTH_1020M, 0));
        assertEquals("Klockan 3. 400 fot", TextFactory.getText(MY_POSITION, EAST_123M, 0));
        assertEquals("Klockan 11. 111 fot", TextFactory.getText(MY_POSITION, WEST_34M, 290));
        assertEquals("Klockan 9. en fot", TextFactory.getText(MY_POSITION, EAST_1FT, 180));
        assertEquals("Klockan 12. 0 fot", TextFactory.getText(MY_POSITION, MY_POSITION, 0));
    } 
 
    private static void setLocale(Locale locale, boolean metric) {
        setLocale(locale, locale, metric);
    } 
 
    private static void setLocale(Locale locale1, Locale locale2, boolean metric) {
        final Configuration config = new Configuration();
        config.locale = locale1;
        final Resources resources = CgeoApplication.getInstance().getResources();
        resources.updateConfiguration(config, resources.getDisplayMetrics());
 
        Locale.setDefault(locale2);
        TestSettings.setUseImperialUnits(!metric);
    } 
}