Package org.zanata.common

Examples of org.zanata.common.LocaleId


        // push target
        TranslationsResource translationsResource =
                buildTranslationResource(
                        buildTextFlowTarget("res1", "hello world translated"));
        restCaller.postTargetDocResource(projectSlug, iterationSlug, docId,
                new LocaleId("pl"), translationsResource, "auto");

        // REST push broadcast event to editor
        assertThat(editorPage.expectBasicTranslationAtRowIndex(0,
                "hello world translated")).isTrue();
    }
View Full Code Here


        TranslationsResource translationsResource =
                buildTranslationResource(
                        buildTextFlowTarget("res1", "hello world translated"));
        restCaller.postTargetDocResource(projectSlug, iterationSlug, docId,
                new LocaleId("pl"), translationsResource, "auto");

        // create and push source but disable copyTrans
        restCaller.createProjectAndVersion(projectSlug, "beta", projectType);
        restCaller.postSourceDocResource(projectSlug, "beta", sourceResource,
                false);
View Full Code Here

            return Optional.absent();
        }
    }

    private void setAttributes(Element tu, ITextFlow tf) {
        LocaleId sourceLocaleId = tf.getLocale();
        String tuid = tf.getQualifiedId();
        String srcLang = sourceLocaleId.getId();
        tu.addAttribute(new Attribute(TMXConstants.SRCLANG, srcLang));
        tu.addAttribute(new Attribute("tuid", tuid));
    }
View Full Code Here

        return sourceTuv;
    }

    private Optional<Element> buildTargetTUV(ITextFlowTarget target) {
        if (target.getState().isTranslated()) {
            LocaleId locId = target.getLocaleId();
            String trgContent = target.getContents().get(0);
            if (trgContent.contains("\0")) {
                String msg =
                        "illegal null character; discarding TargetContents with locale="
                                + locId + ", contents=" + trgContent;
                log.warn(msg);
                return Optional.absent();
            }
            Element tuv = new Element("tuv");
            tuv.addAttribute(new Attribute("xml:lang", XMLConstants.XML_NS_URI,
                    locId.getId()));
            Element seg = new Element("seg");
            seg.appendChild(trgContent);
            tuv.appendChild(seg);
            return Optional.of(tuv);
        }
View Full Code Here

    protected String getMessage(String key, Object... args) {
        return msgs.format(key, args);
    }

    public void setSelectedLocaleId(String localeId) {
        this.selectedLocale = localeDAO.findByLocaleId(new LocaleId(localeId));
    }
View Full Code Here

        if (docLocale == null) {
            // *should* only happen in tests
            log.warn("null locale, assuming 'en'");
            return "en";
        }
        LocaleId docLocaleId = docLocale.getLocaleId();
        return docLocaleId.getId();
    }
View Full Code Here

public class TextContainerAnalyzerDiscriminator implements Discriminator {

    @Override
    public String getAnalyzerDefinitionName(Object value, Object entity,
            String field) {
        LocaleId localeId;

        if (entity instanceof HTextFlow) {
            HTextFlow tf = (HTextFlow) entity;
            localeId = tf.getDocument().getLocale().getLocaleId();
        } else if (entity instanceof HTextFlowTarget) {
            HTextFlowTarget tft = (HTextFlowTarget) entity;
            localeId = tft.getLocale().getLocaleId();
        } else if (entity instanceof TransMemoryUnitVariant) {
            TransMemoryUnitVariant tuv = (TransMemoryUnitVariant) entity;
            localeId = new LocaleId(tuv.getLanguage());
        } else {
            throw new IllegalArgumentException("Illegal text container type: "
                    + entity.getClass().getName());
        }

        return getAnalyzerDefinitionName(localeId.getId());
    }
View Full Code Here

    }

    public void makeSampleLanguages() {
        makeLanguage(LocaleId.FR);

        makeLanguage(new LocaleId("hi"));

        makeLanguage(new LocaleId("pl"));
    }
View Full Code Here

public class LocaleIdBridge implements TwoWayStringBridge {

    @Override
    public String objectToString(Object value) {
        if (value instanceof HLocale) {
            LocaleId locale = ((HLocale) value).getLocaleId();
            return locale.toString();
        } else {
            throw new IllegalArgumentException(
                    "LocaleIdBridge used on a non-LocaleId type: "
                            + value.getClass());
        }
View Full Code Here

        }
    }

    @Override
    public Object stringToObject(String localeId) {
        return new HLocale(new LocaleId(localeId));
    }
View Full Code Here

TOP

Related Classes of org.zanata.common.LocaleId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.