/** * Converts a locale identifier to the internal string value for a language/locale code for this connector. * By default, this simply returns the string of the given LocaleId. * * @param locId * the locale identifier to convert. * @return the internal string code for language/locale code for this connector. */ protected String toInternalCode (LocaleId locId) { return locId.toString(); }
/** * Gets the LCID for a given locale id. * @param locId the locale id to lookup. * @return the LCID value found, or 0 if nothing is found. */ public static int getLCID (LocaleId locId) { LCIDDescr descr = lcidLookup.get(locId.toString()); return descr != null ? descr.lcid : 0; }
@Override protected String toInternalCode (LocaleId locId) { // Get the string output, but in lowercase return locId.toString().toLowerCase(); }
public static String getExpression (LocaleId language) { try { return RESOURCE_BUNDLE.getString(language.toString()); } catch ( MissingResourceException e ) { return DEFAULT_EXP; // Default fall-back } }
/** * Gets the language tag for a given locale id. * @param locId the locale id to lookup. * @return the language tag found, or an empty string. */ public static String getTag (LocaleId locId) { LCIDDescr descr = lcidLookup.get(locId.toString()); return descr != null ? descr.tag : ""; }
public void setSourceLocale (LocaleId locId) { setString(SOURCELOCALE, locId.toString()); }
public void setTargetLocale (LocaleId locId) { setString(TARGETLOCALE, locId.toString()); }
/** * If the filter contains only explicitly listed locales (no regex patterns or masks), then returns the list of * locale tags of those locales. * If there's at least one mask or pattern, an empty list is returned. * @return the list of locale tags. */ public List<String> getExplicitLocaleIds() { List<String> res = new ArrayList<String>(); // Return an empty list if there are patterns or masks if ((patternIncludes.size() != 0) || (regionIncludes.size() != 0) || (userPartIncludes.size() != 0) || (excludes.size() != 0) || (patternExcludes.size() != 0) || (languageExcludes.size() != 0) || (regionExcludes.size() != 0) || (userPartExcludes.size() != 0)) return res; for (LocaleId localeId : includes) res.add(localeId.toString()); for (String language : languageIncludes) res.add(language); return res; }
/** * Registers an LCID for a language tag. * @param lcid the LCID value. * @param tag the language tag. */ private static void registerTag(int lcid, String tag) { LCIDDescr descr; descr = tagLookup.get(lcid); if (descr == null) { Logger localLogger = LoggerFactory.getLogger(LCIDUtil.class); // logger.warn(String.format("Unregistered LCID: 0x%04x %s -- %s\n" + // "registerLCID(\"%s\", \"\", 0x%04x);\n", lcid, tag, // LanguageList.getDisplayName(tag), LanguageList.getDisplayName(tag), lcid)); localLogger.warn(String.format("Unregistered LCID: 0x%04x %s\n", lcid, tag)); return; } tag = LocaleId.fromString(tag).toString(); descr.tag = tag; lcidLookup.put(tag, descr); }
private void setData (Project project) { this.project = project; edHost.setText(project.getHost()); edProjectId.setText(project.getProjectId()); edUser.setText(project.getUser()); edPassword.setText(project.getPassword()); edSource.setText(project.getSourceLocale().toString()); edTarget.setText(project.getTargetLocale().toString()); chkProtectApproved.setSelection(project.getProtectApproved()); }
Field createField(TranslationUnitField field, TranslationUnitVariant tuv, Field.Store store, Field.Index index) { return new Field(field.name(), tuv.getLanguage().toString(), store, index); }
private void processStartDocument (Event event) { try { StartDocument sd = (StartDocument)event.getResource(); // Create the output createWriter(sd); // Writer header writer.write(String.format("%s%s\t%s\t%s"+LINEBREAK, SIGNATURE, VERSION, sd.getLocale().toString(), language.toString())); crumbs = CRUMBS_PREFIX; } catch ( IOException e ) { throw new OkapiIOException("Error writing the header.", e); } }
/** * For "logographic" languages, GMX-V 2.0 defines factors by which the character count * should be divided in order to yield the word count. This method calculates that * word count. * <p> * The result will be <code>0</code> if the language is logographic but does not have * a character count factor defined ({@link GMX#getCharacterCountFactor(LocaleId)} returns * <code>-1d</code>). In this case word counts are not meaningful for the supplied language. * <p> * This method will throw {@link IllegalArgumentException} if the supplied language is * not a logographic script ({@link GMX#isLogographicScript(LocaleId)} returns * <code>false</code>). * * @see web http://www.xtm-intl.com/manuals/gmx-v/GMX-V-2.0.html#LogographicScripts */ public static long countFromLogographicCharacterCount(long characterCount, LocaleId language) { if (!GMX.isLogographicScript(language)) { throw new IllegalArgumentException(language.toString() + " is not a logographic script"); } double charCountFactor = GMX.getCharacterCountFactor(language); if (charCountFactor == -1d) { return 0L; } return Math.round(characterCount / charCountFactor); }
public void setData (QualityCheckSession session) { this.session = session; for ( RawDocument rd : session.getDocuments() ) { lbDocs.add(formatDocument(rd)); } if ( lbDocs.getItemCount() > 0 ) { lbDocs.setSelection(0); } chkAutoRefresh.setSelection(session.getAutoRefresh()); edSourceLocale.setText(session.getSourceLocale().toString()); edTargetLocale.setText(session.getTargetLocale().toString()); updateFileButtons(); }
@Override public void createTargetSegmentation (ISegmenter segmenter, LocaleId targetLocale) { TextContainer tc = getTarget(targetLocale); if ( tc == null ) { throw new OkapiException(String.format("There is no target content for '%s'", targetLocale.toString())); } segmenter.computeSegments(tc); tc.getSegments().create(segmenter.getRanges()); }
@StepParameterMapping(parameterType = StepParameterType.SOURCE_LOCALE) public void setSourceLocale (LocaleId sourceLocale) { this.srcLoc = sourceLocale; srcWordIterator = (RuleBasedBreakIterator) BreakIterator.getWordInstance(ULocale .createCanonical(srcLoc.toString())); RuleBasedBreakIterator.registerInstance(srcWordIterator, srcLoc.toJavaLocale(), BreakIterator.KIND_WORD); }
private void clarifyMarkup(Markup markup) { Nameable nameableMarkupComponent = markup.getNameableMarkupComponent(); if (null != nameableMarkupComponent) { BidirectionalityClarifier bidirectionalityClarifier = new BidirectionalityClarifier( new CreationalParameters( eventFactory, nameableMarkupComponent.getName().getPrefix(), nameableMarkupComponent.getName().getNamespaceURI()), new ClarificationParameters(LocaleId.isBidirectional(targetLocale), LocaleId.hasCharactersAsNumeralSeparators(targetLocale), targetLocale.toString())); bidirectionalityClarifier.clarifyMarkup(markup); } }
deScore1to2Prop = new Property("Txt::EDScore", "", false); fmScore1to2Prop = new Property("Txt::FMScore", "", false); targetLocale2Extra = LocaleId.fromString(targetLocale.toString()+params.getTarget2Suffix()); deScore1to3Prop = new Property("Txt::EDScore1to3", "", false); fmScore1to3Prop = new Property("Txt::FMScore1to3", "", false); targetLocale3Extra = LocaleId.fromString(targetLocale.toString()+params.getTarget3Suffix());
@Override public String processDocumentPart(DocumentPart documentPart) { MarkupSkeleton markupSkeleton = (MarkupSkeleton) documentPart.getSkeleton(); Markup markup = markupSkeleton.getMarkup(); Nameable nameableMarkupComponent = markup.getNameableMarkupComponent(); if (null != nameableMarkupComponent) { // do care about a markup with the start markup component only, as otherwise there is nothing to clarify at all BidirectionalityClarifier bidirectionalityClarifier = new BidirectionalityClarifier( new CreationalParameters( eventFactory, nameableMarkupComponent.getName().getPrefix(), nameableMarkupComponent.getName().getNamespaceURI()), new ClarificationParameters(LocaleId.isBidirectional(targetLocale), LocaleId.hasCharactersAsNumeralSeparators(targetLocale), targetLocale.toString())); bidirectionalityClarifier.clarifyMarkup(markup); } return XMLEventSerializer.serialize(markup); }