Example usage for java.util Locale CHINESE

List of usage examples for java.util Locale CHINESE

Introduction

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

Prototype

Locale CHINESE

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

Click Source Link

Document

Useful constant for language.

Usage

From source file:cn.webank.queue.biz.service.impl.RetryMessagePojoService.java

private static Runnable constructRunnable(final String namespace, final String queueName, final BaseDTO baseDTO,
        final RetryMessageDTO retryDto, final WeBankServiceDispatcher serviceDispatcher,
        // final int timeoutSeconds,
        final SolacePojoService solaceService, final ReloadableResourceBundleMessageSource bundleMessageSource,
        final RetryMessagePojoService retryService, final JsonMapper jsonMapper) {

    Runnable r = new Runnable() {
        public void run() {
            // 4.1 dispatch service

            try {
                //retry?
                long currentTime = System.currentTimeMillis();
                retryDto.addRetryTimes();
                retryDto.setLastExecutedTime(currentTime);

                BizErrors errors = new BizErrors();

                // TODO ?2
                serviceDispatcher.dispatch(baseDTO.getServiceId(), retryDto.getJsonMessage(), errors);

                // handle result
                if (errors.hasErrors()) {
                    StringBuilder sb = new StringBuilder();
                    boolean isFirst = true;
                    for (BizError error : errors.getAllErrors()) {

                        if (!isFirst) {
                            sb.append("<br />");
                        }/*  w w w . j a  va  2s. c om*/
                        sb.append(bundleMessageSource.getMessage(error.getCode(), error.getArguments(),
                                "", Locale.CHINESE));
                        isFirst = false;

                    }

                    LOG.error("biz error:" + sb.toString() + ",message:" + retryDto.getJsonMessage());

                    handleBizException(retryDto);
                } else {
                    LOG.info("retry message success. key:" + retryDto.getKey() + " ");
                }

            } catch (Exception e) {
                // ?
                LOG.error("distach service error,message:" + retryDto.getJsonMessage(), e);
                handleSysException(namespace, queueName, retryDto, e, retryService, jsonMapper);

            }

        }
    };

    return r;

}

From source file:de.hybris.platform.yb2bacceleratorcore.jalo.ProductQuote.java

@SuppressWarnings("deprecation")
public void createAndSave(final String description, final String productID) {
    final ProductQuoteModel pqmodel = new ProductQuoteModel();
    final ProductModel pmodel = getProductService().getProductForCode(productID);
    final B2BCustomerModel cmodel = (B2BCustomerModel) getB2bCustomerService().getCurrentB2BCustomer();
    pqmodel.setCustomer(cmodel);//from w  w  w . j a v  a 2 s .  c  o m
    pqmodel.setProduct(pmodel);
    pqmodel.setDescription(description);
    getModelService().save(pqmodel);

    //create workflows
    FlexibleSearchQuery query = new FlexibleSearchQuery(
            "SELECT {pk} FROM {WorkflowTemplate} WHERE {code}='ProductQuoteWFTemplate'");
    final WorkflowTemplateModel wftmodel = flexibleSearchService.searchUnique(query);
    //final List<WorkflowTemplateModel> list = result.getResult();
    //final WorkflowTemplateModel wftmodel = list.iterator().next();

    final Collection<VariantProductModel> variants = pqmodel.getProduct().getVariants();
    WorkflowModel workflow;
    final List<WorkflowItemAttachmentModel> attachList = new ArrayList<WorkflowItemAttachmentModel>();
    WorkflowItemAttachmentModel attachment;

    for (final VariantProductModel variant : variants) {
        query = new FlexibleSearchQuery("SELECT {supplier} FROM {PlatformSupplierVariantProduct} WHERE {code}='"
                + variant.getCode() + "'");
        final EmployeeModel supplier = flexibleSearchService.searchUnique(query);

        workflow = workflowService.createWorkflow(wftmodel, pqmodel);
        workflow.setDescription(description);

        attachList.clear();
        //add quote attachment
        attachment = modelService.create(WorkflowItemAttachmentModel.class);
        attachment.setItem(pqmodel);
        attachment.setCode("Quotation");
        attachment.setWorkflow(workflow);
        attachList.add(attachment);

        //add product attachment
        attachment = modelService.create(WorkflowItemAttachmentModel.class);
        attachment.setItem(variant);
        attachment.setCode("QuotedProduct");
        attachment.setWorkflow(workflow);
        attachList.add(attachment);

        //add customer attachment
        attachment = modelService.create(WorkflowItemAttachmentModel.class);
        attachment.setItem(cmodel);
        attachment.setCode("QuotingCustomer");
        attachment.setWorkflow(workflow);
        attachList.add(attachment);

        final WorkflowActionModel action = workflow.getActions().iterator().next();
        action.setPrincipalAssigned(supplier);
        action.setAttachments(attachList);
        action.setDescription(description, Locale.CHINESE);

        /*
         * final WorkflowItemAttachmentModel attachment = modelService.create(WorkflowItemAttachmentModel.class);
         * attachment.setItem(pqmodel); attachment.setWorkflow(workflow); attachment.setCode("SampleProductAtt");
         * workflow.setAttachments(Collections.singletonList(attachment));
         */

        workflowProcessingService.startWorkflow(workflow);

    }
}

From source file:org.talend.designer.core.ui.preferences.I18nPreferencePage.java

@Override
protected void createFieldEditors() {
    // Adds a combo for language selection.

    String spanish = "Espa\u00F1ol"; //$NON-NLS-1$
    byte[] utf8Bytes;
    try {//  w w w.j av a  2 s  .c o m
        utf8Bytes = spanish.getBytes("UTF8"); //$NON-NLS-1$
        spanish = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        spanish = "Spanish"; //$NON-NLS-1$
    }

    String russian = "\u0420\u0443\u0441\u0441\u043A\u0438\u0439"; //$NON-NLS-1$
    try {
        utf8Bytes = russian.getBytes("UTF8"); //$NON-NLS-1$
        russian = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        russian = "Russian"; //$NON-NLS-1$
    }

    String greek = "\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac"; //$NON-NLS-1$
    try {
        utf8Bytes = greek.getBytes("UTF8"); //$NON-NLS-1$
        greek = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        greek = "Greek"; //$NON-NLS-1$
    }

    String arabic = "\u0627\u0644\u0639\u0631\u0628\u064a\u0647"; //$NON-NLS-1$
    try {
        utf8Bytes = arabic.getBytes("UTF8"); //$NON-NLS-1$
        arabic = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        arabic = "Arabic"; //$NON-NLS-1$
    }

    String serbian = "\u0421\u0440\u043f\u0441\u043a\u0438"; //$NON-NLS-1$
    try {
        utf8Bytes = serbian.getBytes("UTF8"); //$NON-NLS-1$
        serbian = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        serbian = "Serbian"; //$NON-NLS-1$
    }

    String[][] entryNamesAndValues = {
            { Locale.ENGLISH.getDisplayLanguage(Locale.ENGLISH), Locale.ENGLISH.getLanguage() },
            { Locale.FRENCH.getDisplayLanguage(Locale.FRENCH), Locale.FRENCH.getLanguage() },
            { Locale.CHINESE.getDisplayLanguage(Locale.CHINESE), "zh_CN" },
            { Locale.GERMAN.getDisplayLanguage(Locale.GERMAN), Locale.GERMAN.getLanguage() },
            { Locale.JAPANESE.getDisplayLanguage(Locale.JAPANESE), Locale.JAPANESE.getLanguage() },
            { Locale.ITALIAN.getDisplayLanguage(Locale.ITALIAN), Locale.ITALIAN.getLanguage() },
            { "Brasil", "pt_BR" }, //$NON-NLS-1$ //$NON-NLS-2$ 
            { spanish, "es" }, { russian, "ru" }, //$NON-NLS-1$ //$NON-NLS-2$ 
            { Locale.KOREA.getDisplayLanguage(Locale.KOREA), "kr" }, { "Turkish", "tr" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
            { greek, "el" }, { "Hrvatski", "hr" }, { arabic, "ar" }, { serbian, "sr" }, { "Polski", "pl" },
            { "Romanian", "ro" }, { "Netherlands", "nl" } }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ // /$NON-NLS-7$ 
    languageSelectionEditor = new OneLineComboFieldEditor(ITalendCorePrefConstants.LANGUAGE_SELECTOR,
            Messages.getString("I18nPreferencePage.needRestart"), entryNamesAndValues, getFieldEditorParent()); //$NON-NLS-1$
    addField(languageSelectionEditor);

    Composite composite = getFieldEditorParent();
    LabelFieldEditor importAll = new LabelFieldEditor(
            Messages.getString("I18nPreferencePage.translationInformation"), //$NON-NLS-1$
            composite);
    addField(importAll);

    Button allUpdate = new Button(composite, SWT.FLAT);
    allUpdate.setText(Messages.getString("I18nPreferencePage.importBabili")); //$NON-NLS-1$
    allUpdate.setLayoutData(new GridData());

    allUpdate.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // import all update from Babili
            // select the .zip file
            FileDialog fd = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    SWT.OPEN);
            fd.setText("Open"); //$NON-NLS-1$
            fd.setFilterPath("C:" + fs); //$NON-NLS-1$
            String[] filterExtensions = { "*.zip" }; //$NON-NLS-1$
            fd.setFilterExtensions(filterExtensions);
            String selected = fd.open();
            if (selected != null) {
                isBabiliButtonClicked = true;
                runProgressMonitorDialog(selected);
                if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        Messages.getString("I18nPreferencePage.restart"), //$NON-NLS-1$
                        Messages.getString("I18nPreferencePage.restartButton"))) {
                    PlatformUI.getWorkbench().restart();
                }
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            // Nothing to do
        }
    });

    // added by nma
    Button restoredefault = new Button(composite, SWT.FLAT);
    restoredefault.setText("Restore Defaults"); //$NON-NLS-1$
    restoredefault.setLayoutData(new GridData());
    restoredefault.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            // Nothing to do
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            isBabiliButtonClicked = true;
            runProgressMonitorDialog(Messages.getString("I18nPreferencePage.restoreDefault")); //$NON-NLS-1$
            if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    Messages.getString("I18nPreferencePage.restart"),
                    Messages.getString("I18nPreferencePage.restartButton"))) {
                PlatformUI.getWorkbench().restart();
            }
        }
    });
}

From source file:divya.myvision.TessActivity.java

public void setLang(String lang) {
    Locale locale;/*from  w  w w  . java  2 s  . com*/
    if (lang.equals("Spanish")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                Locale locSpanish = new Locale("spa", "MEX");
                tts.setLanguage(locSpanish);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("spa", "MEX");
    }

    else if (lang.equals("French")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.FRENCH);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("fr");
    } else if (lang.equals("Japanese")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.JAPANESE);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("ja");
    } else if (lang.equals("Chinese")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.CHINESE);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("zh");
    } else if (lang.equals("German")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.GERMAN);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("de");
    } else if (lang.equals("Italian")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.ITALIAN);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("it");
    } else if (lang.equals("Korean")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.KOREAN);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("ko");
    } else if (lang.equals("Hindi")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                Locale locHindhi = new Locale("hi");
                tts.setLanguage(locHindhi);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("hi");
    } else if (lang.equals("Russian")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                Locale locHindhi = new Locale("ru");
                tts.setLanguage(locHindhi);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("ru");
    } else {
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.US);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("en");
    }
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.setLocale(locale);
    this.getApplicationContext().getResources().updateConfiguration(config, null);

}

From source file:hk.idv.kenson.jrconsole.Console.java

/**
 * //from w ww  .j ava2 s. co  m
 * @param localeString
 * @return
 */
private static Locale getLocale(String localeString) {
    if ("default".equals(localeString))
        return Locale.getDefault();
    if ("canada".equals(localeString))
        return Locale.CANADA;
    if ("canada_french".equals(localeString))
        return Locale.CANADA_FRENCH;
    if ("china".equals(localeString))
        return Locale.CHINA;
    if ("chinese".equals(localeString))
        return Locale.CHINESE;
    if ("english".equals(localeString))
        return Locale.ENGLISH;
    if ("franch".equals(localeString))
        return Locale.FRANCE;
    if ("german".equals(localeString))
        return Locale.GERMAN;
    if ("germany".equals(localeString))
        return Locale.GERMANY;
    if ("italian".equals(localeString))
        return Locale.ITALIAN;
    if ("italy".equals(localeString))
        return Locale.ITALY;
    if ("japan".equals(localeString))
        return Locale.JAPAN;
    if ("japanese".equals(localeString))
        return Locale.JAPANESE;
    if ("korea".equals(localeString))
        return Locale.KOREA;
    if ("korean".equals(localeString))
        return Locale.KOREAN;
    if ("prc".equals(localeString))
        return Locale.PRC;
    if ("simplified_chinese".equals(localeString))
        return Locale.SIMPLIFIED_CHINESE;
    if ("taiwan".equals(localeString))
        return Locale.TAIWAN;
    if ("traditional_chinese".equals(localeString))
        return Locale.TRADITIONAL_CHINESE;
    if ("uk".equals(localeString))
        return Locale.UK;
    if ("us".equals(localeString))
        return Locale.US;

    String parts[] = localeString.split("_", -1);
    if (parts.length == 1)
        return new Locale(parts[0]);
    else if (parts.length == 2)
        return new Locale(parts[0], parts[1]);
    else
        return new Locale(parts[0], parts[1], parts[2]);
}

From source file:com.jcommerce.web.front.action.BaseAction.java

public Lang getLangMap(HttpServletRequest request) {
    // default//from   w w  w  .j  a v a  2 s. c  o m
    String locale = Locale.CHINESE.toString();
    String reqLocale = (String) request.getParameter(KEY_LOCALE);
    debug("reqLocale: " + reqLocale);
    if (reqLocale != null) {
        locale = reqLocale;
    } else {
        String sessionLocale = (String) request.getSession().getAttribute(KEY_LOCALE);
        debug("sessionLocale: " + sessionLocale);
        if (sessionLocale != null) {
            locale = sessionLocale;
        }
    }
    Locale loc = null;
    try {
        loc = ResourceUtil.parseLocale(locale);
    } catch (Exception ex) {
        // invalid locale string. should avoid
        ex.printStackTrace();
    }

    // remember the choice
    request.getSession().setAttribute(KEY_LOCALE, locale);

    Lang.setCurrentLocale(loc);
    Lang lang = (Lang) request.getAttribute("lang");
    if (lang == null) {
        lang = Lang.getInstance();
        request.setAttribute("lang", lang);
    }
    return lang;
}

From source file:org.alfresco.repo.content.AbstractWritableContentStoreTest.java

/**
 * Checks that the various methods of obtaining a reader are supported.
 *///from  www  .  j a va 2 s .com
@Test
public synchronized void testGetReader() throws Exception {
    ContentStore store = getStore();
    ContentWriter writer = store.getWriter(ContentStore.NEW_CONTENT_CONTEXT);
    String contentUrl = writer.getContentUrl();

    // Check that a reader is available from the store
    ContentReader readerFromStoreBeforeWrite = store.getReader(contentUrl);
    assertNotNull("A reader must always be available from the store", readerFromStoreBeforeWrite);

    // check that a reader is available from the writer
    ContentReader readerFromWriterBeforeWrite = writer.getReader();
    assertNotNull("A reader must always be available from the writer", readerFromWriterBeforeWrite);

    String content = "Content for testGetReader";

    // write some content
    long before = System.currentTimeMillis();
    this.wait(1000L);
    writer.setMimetype("text/plain");
    writer.setEncoding("UTF-8");
    writer.setLocale(Locale.CHINESE);
    writer.putContent(content);
    this.wait(1000L);
    long after = System.currentTimeMillis();

    // get a reader from the store
    ContentReader readerFromStore = store.getReader(contentUrl);
    assertNotNull(readerFromStore);
    assertTrue(readerFromStore.exists());
    // Store-provided readers don't have context other than URLs
    // assertEquals(writer.getContentData(), readerFromStore.getContentData());
    assertEquals(content, readerFromStore.getContentString());

    // get a reader from the writer
    ContentReader readerFromWriter = writer.getReader();
    assertNotNull(readerFromWriter);
    assertTrue(readerFromWriter.exists());
    assertEquals(writer.getContentData(), readerFromWriter.getContentData());
    assertEquals(content, readerFromWriter.getContentString());

    // get another reader from the reader
    ContentReader readerFromReader = readerFromWriter.getReader();
    assertNotNull(readerFromReader);
    assertTrue(readerFromReader.exists());
    assertEquals(writer.getContentData(), readerFromReader.getContentData());
    assertEquals(content, readerFromReader.getContentString());

    // check that the length is correct
    int length = content.getBytes(writer.getEncoding()).length;
    assertEquals("Reader content length is incorrect", length, readerFromWriter.getSize());

    // check that the last modified time is correct
    long modifiedTimeCheck = readerFromWriter.getLastModified();

    // On some versionms of Linux (e.g. Centos) this test won't work as the 
    // modified time accuracy is only to the second.
    long beforeSeconds = before / 1000L;
    long afterSeconds = after / 1000L;
    long modifiedTimeCheckSeconds = modifiedTimeCheck / 1000L;

    assertTrue("Reader last modified is incorrect", beforeSeconds <= modifiedTimeCheckSeconds);
    assertTrue("Reader last modified is incorrect", modifiedTimeCheckSeconds <= afterSeconds);
}

From source file:org.alfresco.repo.content.AbstractWritableContentStoreTest.java

@Test
public void testMimetypAndEncodingAndLocale() throws Exception {
    ContentWriter writer = getWriter();/*from  w  ww .  j a  v a  2  s.  c  o  m*/
    // set mimetype and encoding
    writer.setMimetype("text/plain");
    writer.setEncoding("UTF-16");
    writer.setLocale(Locale.CHINESE);

    // create a UTF-16 string
    String content = "A little bit o' this and a little bit o' that";
    byte[] bytesUtf16 = content.getBytes("UTF-16");
    // write the bytes directly to the writer
    OutputStream os = writer.getContentOutputStream();
    os.write(bytesUtf16);
    os.close();

    // now get a reader from the writer
    ContentReader reader = writer.getReader();
    assertEquals("Writer -> Reader content URL mismatch", writer.getContentUrl(), reader.getContentUrl());
    assertEquals("Writer -> Reader mimetype mismatch", writer.getMimetype(), reader.getMimetype());
    assertEquals("Writer -> Reader encoding mismatch", writer.getEncoding(), reader.getEncoding());
    assertEquals("Writer -> Reader locale mismatch", writer.getLocale(), reader.getLocale());

    // now get the string directly from the reader
    String contentCheck = reader.getContentString(); // internally it should have taken care of the encoding
    assertEquals("Encoding and decoding of strings failed", content, contentCheck);
}

From source file:org.alfresco.repo.node.NodeServiceTest.java

@Test
public void testLocaleSupport() throws Exception {
    // Ensure that the root node has the default locale
    Locale locale = (Locale) nodeService.getProperty(rootNodeRef, ContentModel.PROP_LOCALE);
    assertNotNull("Locale property must occur on every node", locale);
    assertEquals("Expected default locale on the root node", I18NUtil.getLocale(), locale);
    assertTrue("Every node must have sys:localized",
            nodeService.hasAspect(rootNodeRef, ContentModel.ASPECT_LOCALIZED));

    // Now switch to a specific locale and create a new node
    I18NUtil.setLocale(Locale.CANADA_FRENCH);

    // Create a node using an explicit locale
    NodeRef nodeRef1 = nodeService/*from   w w  w.j  a  v  a  2  s.  c o  m*/
            .createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
                    QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
                    ContentModel.TYPE_CONTAINER,
                    Collections.singletonMap(ContentModel.PROP_LOCALE, (Serializable) Locale.GERMAN))
            .getChildRef();
    assertTrue("Every node must have sys:localized",
            nodeService.hasAspect(nodeRef1, ContentModel.ASPECT_LOCALIZED));
    assertEquals("Didn't set the explicit locale during create. ", Locale.GERMAN,
            nodeService.getProperty(nodeRef1, ContentModel.PROP_LOCALE));

    // Create a node using the thread's locale
    NodeRef nodeRef2 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
            ContentModel.TYPE_CONTAINER).getChildRef();
    assertTrue("Every node must have sys:localized",
            nodeService.hasAspect(nodeRef2, ContentModel.ASPECT_LOCALIZED));
    assertEquals("Didn't set the locale during create. ", Locale.CANADA_FRENCH,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));

    // Switch Locale and modify ml:text property
    I18NUtil.setLocale(Locale.CHINESE);
    nodeService.setProperty(nodeRef2, ContentModel.PROP_DESCRIPTION, "Chinese description");
    I18NUtil.setLocale(Locale.FRENCH);
    nodeService.setProperty(nodeRef2, ContentModel.PROP_DESCRIPTION, "French description");

    // Expect that we have MLText (if we are ML aware)
    boolean wasMLAware = MLPropertyInterceptor.setMLAware(true);
    try {
        MLText checkDescription = (MLText) nodeService.getProperty(nodeRef2, ContentModel.PROP_DESCRIPTION);
        assertEquals("Chinese description", checkDescription.getValue(Locale.CHINESE));
        assertEquals("French description", checkDescription.getValue(Locale.FRENCH));
    } finally {
        MLPropertyInterceptor.setMLAware(wasMLAware);
    }
    // But the node locale must not have changed
    assertEquals("Node modification should not affect node locale. ", Locale.CANADA_FRENCH,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));

    // Now explicitly set the node's locale
    nodeService.setProperty(nodeRef2, ContentModel.PROP_LOCALE, Locale.ITALY);
    assertEquals("Node locale must be settable. ", Locale.ITALY,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));
    // But mltext must be unchanged
    assertEquals("Canada-French must be closest to French. ", "French description",
            nodeService.getProperty(nodeRef2, ContentModel.PROP_DESCRIPTION));

    // Finally, ensure that setting Locale to 'null' is takes the node back to its original locale
    nodeService.setProperty(nodeRef2, ContentModel.PROP_LOCALE, null);
    assertEquals("Node locale set to 'null' does nothing. ", Locale.ITALY,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));
    nodeService.removeProperty(nodeRef2, ContentModel.PROP_LOCALE);
    assertEquals("Node locale removal does nothing. ", Locale.ITALY,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));

    // Mass-set the properties, changing the locale in the process
    Map<QName, Serializable> props = nodeService.getProperties(nodeRef2);
    props.put(ContentModel.PROP_LOCALE, Locale.GERMAN);
    nodeService.setProperties(nodeRef2, props);
    assertEquals("Node locale not set in setProperties(). ", Locale.GERMAN,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));
}