/** * Indicates if a locale id is null or empty. * @param locale the locale id to examine. * @return true if the given locale id is null or empty, false otherwise. */ static public boolean isNullOrEmpty (LocaleId locale) { return (( locale == null ) || ( locale.equals(LocaleId.EMPTY) )); }
/** * Counts the number of <tuv>s for a certain language. * @param lang The language to be counted. * @return The number of <tuv>s. Result above 1 indicates a duplicate. */ int langCount (LocaleId lang) { int counter=0; for (TmxTuv tmxTuv : tuvs){ if ( tmxTuv.lang.equals(lang) ) { counter++; } } return counter; }
/** * Gets the TuvXmlLang based on current language and source and specified target lang * @return TuvXmlLang.SOURCE, TuvXmlLang.TARGET, and TuvXmlLang.OTHER */ private TuvXmlLang getTuvTrgType(LocaleId lang){ if ( lang.equals(srcLang) ) { return TuvXmlLang.SOURCE; } else if ( lang.equals(trgLang) ) { return TuvXmlLang.TARGET; } else { return TuvXmlLang.OTHER; } }
/** * Helper method. */ private void removeFromExcludes(LocaleId localeId) { for (int i = excludes.size() - 1; i >= 0; i--) { LocaleId item = excludes.get(i); if (item == null) continue; if (item.equals(localeId)) excludes.remove(i); } }
private INameable setPropertyBasedOnLocale(INameable resource, LocaleId locale, Property property) { if (locale == null) { resource.setSourceProperty(property); } else if (locale.equals(LocaleId.EMPTY)) { resource.setProperty(property); } else { resource.setTargetProperty(locale, property); } return resource; }
/** * Finds either source or target reference in the skeleton. If locId is specified, then its target reference is sought for. * @param skel the skeleton being sought for the reference. * @param locId the locale to search the reference for. * @return index in the list of skeleton parts for the skeleton part containing the reference. */ public static int findTuRefInSkeleton(GenericSkeleton skel, LocaleId locId) { if ( skel == null ) return -1; List<GenericSkeletonPart> list = skel.getParts(); for ( int i=0; i<list.size(); i++ ) { GenericSkeletonPart part = list.get(i); String st = part.toString(); if ( Util.isEmpty(st) ) continue; if ( st.equalsIgnoreCase(TU_REF) ) { if ( Util.isNullOrEmpty(locId) ) { return i; } else if ( locId.equals(part.getLocale()) ) { return i; } } } return -1; }
/** * Creates a new TextMatcher object. * @param locale1 locale of the first language. * @param locale2 locale of the second language. */ public TextMatcher (LocaleId locale1, LocaleId locale2) { // Create the first breaker. breaker1 = BreakIterator.getWordInstance(locale1.toJavaLocale()); if ( locale1.equals(locale2) ) { // Use the same one if the second language is the same. breaker2 = breaker1; } else { // If two different languages: create a second breaker. breaker2 = BreakIterator.getWordInstance(locale2.toJavaLocale()); } }
private void processTargetPlaceholder(GenericSkeletonPart part, IResource resource, MultiEvent me, String resId, int tuCounter, int dpCounter) { // For both isMultilingual true/false // if (part.getLocale() == getTargetLocale()) { if (part.getLocale().equals(getTargetLocale())) { flushSkeleton(resId, ++dpCounter, me); addTU(me, resId, ++tuCounter, (ITextUnit)resource); // The target placeholder's content should become a TU } else { //newSkel.add(skelWriter.getContent((TextUnit) resource, getTargetLocale(), 1)); newSkel.add(skelWriter.getContent((ITextUnit)resource, part.getLocale(), EncoderContext.SKELETON)); } }
if (srcLang.equals(LocaleId.EMPTY)) { if (hSrcLang == null) { throw new OkapiBadFilterInputException("Header element is missing the srclang attribute.");
if (segmenter.getLanguage().equals(LocaleId.EMPTY)) return segmenter;
prop = resource.getSourceProperty(name); else if ( locToUse.equals(LocaleId.EMPTY) ) { // Use the resource-level properties prop = resource.getProperty(name);
if (languageCode.equals(segmenter.getLanguage()) && (cascade == segmenter.cascade())) return segmenter;
if ( !srcLoc.equals(input.getSourceLocale()) ) { logger.warn("The source locale declared in the file ('{}') is not the expected one ('{}')\n{} will be used.", srcLoc.toString(), input.getSourceLocale().toString(), input.getSourceLocale().toString()); if ( !trgLoc.equals(input.getTargetLocale()) ) { logger.warn("The target locale declared in the file ('{}') is not the expected one ('{}')\n{} will be used.", trgLoc.toString(), input.getTargetLocale().toString(), input.getTargetLocale().toString());
if (part.getLocale().equals(getTargetLocale())) {