Example usage for java.util Locale FRENCH

List of usage examples for java.util Locale FRENCH

Introduction

In this page you can find the example usage for java.util Locale FRENCH.

Prototype

Locale FRENCH

To view the source code for java.util Locale FRENCH.

Click Source Link

Document

Useful constant for language.

Usage

From source file:org.jasig.cas.web.view.CasReloadableMessageBundleTests.java

@Test(expected = NoSuchMessageException.class)
public void testExpectExceptionWhenCodeNotFound() {
    this.loader.setUseCodeAsDefaultMessage(false);
    this.loader.getMessage("does.not.exist", null, Locale.FRENCH);
}

From source file:eu.trentorise.opendata.commons.test.jackson.OdtCommonsModuleTest.java

@Test
public void testDict() throws JsonProcessingException, IOException {

    testJsonConv(objectMapper, LOG, Dict.of("a", "b"));
    testJsonConv(objectMapper, LOG, Dict.of(Locale.FRENCH, "a", "b"));

    Dict dict = objectMapper.readValue("{}", Dict.class);
    assertEquals(Dict.of(), dict);//from   w  ww . j  ava 2 s  .c o  m

    try {
        Dict dict_2 = objectMapper.readValue("{\"it\":null}", Dict.class);
        Assert.fail("Should have validated the dict!");
    } catch (Exception ex) {

    }
}

From source file:org.xwiki.test.rest.PageTranslationResourceTest.java

@Before
@Override/*from  w w  w  . j ava  2s. c om*/
public void setUp() throws Exception {
    super.setUp();

    this.wikiName = getWiki();
    this.space = getTestClassName();
    this.spaces = Arrays.asList(this.space);
    this.pageName = getTestMethodName();
    this.referenceDefault = new DocumentReference(this.wikiName, this.spaces, this.pageName);
    this.referenceFR = new DocumentReference(this.wikiName, this.spaces, this.pageName, Locale.FRENCH);

    // Clean
    this.testUtils.rest().delete(this.referenceFR);
    this.testUtils.rest().delete(this.referenceDefault);
}

From source file:org.marketcetera.util.log.I18NMessageProviderTest.java

@Test
public void retrievals() {
    assertEquals("Hello", TestMessages.PROVIDER.getText(TestMessages.HELLO_MSG));
    assertEquals("Hello World!", TestMessages.PROVIDER.getText(TestMessages.HELLO_TITLE, "World"));
    assertEquals("Bonjour", TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.HELLO_MSG));
    assertEquals("Bonjour Le Monde!",
            TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.HELLO_TITLE, "Le Monde"));

    Locale saved = Locale.getDefault();
    try {//from ww  w. j a  v a 2s .com
        Locale.setDefault(Locale.ROOT);
        assertEquals("Hello", TestMessages.PROVIDER.getText(Locale.GERMAN, TestMessages.HELLO_MSG));
        Locale.setDefault(Locale.JAPANESE);
        assertEquals("Hello", TestMessages.PROVIDER.getText(Locale.GERMAN, TestMessages.HELLO_MSG));
        Locale.setDefault(Locale.FRENCH);
        assertEquals("Bonjour", TestMessages.PROVIDER.getText(Locale.GERMAN, TestMessages.HELLO_MSG));
    } finally {
        Locale.setDefault(saved);
    }

    assertEquals("Hello a {0} 'a' \"a\" b!", TestMessages.PROVIDER.getText(TestMessages.HELLO_ECHO, "a", "b"));
    assertEquals("Bonjour a {0} 'a' \"a\" {1}!",
            TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.HELLO_ECHO, "a"));
    assertEquals("Bonjour a {0} 'a' \"a\" b!",
            TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.HELLO_ECHO, "a", "b", "c"));

    assertEquals("There are no orders ma'am.", TestMessages.PROVIDER.getText(TestMessages.CHOICE_MSG, 0));
    assertEquals("There is just one order ma'am.", TestMessages.PROVIDER.getText(TestMessages.CHOICE_MSG, 1));
    assertEquals("There are 2 orders ma'am.", TestMessages.PROVIDER.getText(TestMessages.CHOICE_MSG, 2));

    assertEquals("Pas des ordres ma'am.",
            TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.CHOICE_MSG, 0));
    assertEquals("Seulemont un ordre ma'am.",
            TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.CHOICE_MSG, 1));
    assertEquals("Il y a 2 ordres ma'am.",
            TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.CHOICE_MSG, 2));

    assertEquals("Hello {0}!", TestMessages.PROVIDER.getText(TestMessages.HELLO_TITLE, (Object[]) null));
    assertEquals("Hello null!", TestMessages.PROVIDER.getText(TestMessages.HELLO_TITLE, (Object) null));

    ActiveLocale.setProcessLocale(Locale.FRENCH);
    assertEquals("Bonjour", TestMessages.PROVIDER.getText(TestMessages.HELLO_MSG));
    assertEquals("Bonjour Le Monde!", TestMessages.PROVIDER.getText(TestMessages.HELLO_TITLE, "Le Monde"));
}

From source file:org.modelibra.util.NatLang.java

/**
 * Sets the language with the location for text resources.
 * //from   w ww.j  a  v  a 2  s .  c  o m
 * @param language
 *            language
 * @param textResources
 *            text resources
 */
public void setNaturalLanguage(String language, String textResources) {
    try {
        if ((language == null) || (language.equals("en"))) {
            locale = Locale.ENGLISH;
        } else if (language.equals("fr")) {
            locale = Locale.FRENCH;
        } else if (language.equals("ba")) {
            locale = new Locale("ba"); // bosnian language
        } else if (language.equals("hr")) {
            locale = new Locale("hr"); // croatian language
        } else if (language.equals("sr")) {
            locale = new Locale("sr"); // serbian language
        } else { // other languages are not supported, English used
            locale = Locale.ENGLISH;
        }
        resource = ResourceBundle.getBundle(textResources, locale);
    } catch (MissingResourceException e) {
        System.out.println(e.getMessage());
    }
}

From source file:modelibra.swing.app.config.NatLang.java

/**
 * Sets the language with the location for text resources.
 * //from   ww w.  java  2 s . c om
 * @param language
 *            language
 * @param textResources
 *            text resources
 */
public void setNaturalLanguage(String language, String textResources) {
    try {
        if ((language == null) || (language.equals("en"))) {
            locale = Locale.ENGLISH;
        } else if (language.equals("fr")) {
            locale = Locale.FRENCH;
        } else if (language.equals("ba")) {
            locale = new Locale("ba"); // bosnian language
        } else if (language.equals("hr")) {
            locale = new Locale("hr"); // croatian language
        } else if (language.equals("sr")) {
            locale = new Locale("sr"); // serbian language
        } else { // other languages are not supported, English used
            locale = Locale.ENGLISH;
        }
        resource = ResourceBundle.getBundle(textResources, locale);
    } catch (MissingResourceException e) {
        System.out.println(e.getMessage());
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

From source file:org.xwiki.test.rest.PageTranslationResourceTest.java

@Test
public void testGETNotExistingPage() throws Exception {
    GetMethod getMethod = executeGet(buildURI(PageTranslationResource.class, getWiki(),
            Arrays.asList("NOTEXISTING"), "NOTEXISTING", Locale.FRENCH).toString());
    assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_NOT_FOUND, getMethod.getStatusCode());
}

From source file:com.sun.faces.demotest.cardemo.TestCarDemo.java

/**
 * <p>Load the main page.  Assumptions: there are exactly four
 * buttons, in a certain order, to select each locale.  For each
 * button, press it, and call doStoreFront() on the result.</p>
 *///  w w  w  . j a  va 2s  .c  o m

public void testCarDemo() throws Exception {

    // for each of the language links run the test
    HtmlPage page = (HtmlPage) getInitialPage();
    List buttons = getAllElementsOfGivenClass(page, null, HtmlSubmitInput.class);
    HtmlSubmitInput button = null;
    int i, j = 0;
    Locale[] locales = { Locale.ENGLISH, Locale.GERMAN, Locale.FRENCH, new Locale("es", "") };

    for (i = 0; i < locales.length; i++) {
        resources = ResourceBundle.getBundle("carstore.bundles.Resources", locales[i]);
        carBundles = new ResourceBundle[carBundleNames.length];
        for (j = 0; j < carBundleNames.length; j++) {
            carBundles[j] = ResourceBundle.getBundle(carBundleNames[j], locales[i]);
        }

        button = (HtmlSubmitInput) buttons.get(i);
        if (log.isTraceEnabled()) {
            log.trace("Running test for language: " + button.asText());
        }
        doStoreFront((HtmlPage) button.click());
    }
}

From source file:eu.trentorise.opendata.commons.test.jackson.OdtCommonsModuleTest.java

@Test
public void testLocalizedString() throws JsonProcessingException, IOException {

    testJsonConv(objectMapper, LOG, LocalizedString.of(Locale.FRENCH, "a"));

    String json = changeField(objectMapper, LOG, LocalizedString.of(Locale.ITALIAN, "a"), "string",
            NullNode.instance);/*from w w w. j ava  2s  .  c om*/

    try {
        objectMapper.readValue(json, LocalizedString.class);
        Assert.fail("Should not accept null values!");
    } catch (Exception ex) {

    }

    try {
        objectMapper.readValue("{\"string\":\"a\"}", LocalizedString.class);
        Assert.fail("Should have failed because no locale field was provided!");
    } catch (Exception ex) {

    }

}

From source file:com.salesmanager.core.util.LabelUtil.java

private void getLocale(String lang) {

    if (StringUtils.isBlank(lang)) {
        lang = LanguageUtil.getDefaultLanguage();
    }/* w  w  w .  j  av a  2s . co m*/

    if (lang.equals("en")) {
        setLocale(Locale.ENGLISH);
    } else if (lang.equals("fr")) {
        setLocale(Locale.FRENCH);
    } else {
        setLocale(new Locale(lang));
    }
}