/** * Remove the translation corresponding to the given locale code. * * @param locale locale code * @throws java.lang.IllegalArgumentException if locale is blank */ public void removeTranslation(String locale) { Preconditions.checkArgument(StringUtils.isNotBlank(locale)); Translation translation = getTranslation(locale); if (translation != null) { this.getTranslations().remove(translation); } }
private boolean translationHasChanged(Key targetKey, String localeCode, String translationValue) { Translation translation = targetKey.getTranslation(localeCode); return translation == null || !translation.getValue().equals(translationValue); } }
Translation getTranslationWithFallBack(Key loadedKey, List<ULocale> localeIterator) { Translation translation = null; for (ULocale uLocale : localeIterator) { translation = loadedKey.getTranslation(uLocale.getBaseName()); if (translation != null) { break; } } return translation; }
private boolean translationHasChanged(Key key, String locale, String newTranslation) { Translation translation = key.getTranslation(locale); return translation == null || !newTranslation.equals(translation.getValue()); }
/** * Removes the translation corresponding to the given locale code. * * @param locale locale code * @throws java.lang.IllegalArgumentException if the locale is null or empty * or contains other characters than letters and "-". */ public void removeTranslation(String locale) { LocaleCodeSpecification.assertCode(locale); Translation translation = getTranslation(locale); if (translation != null) { this.translations.remove(translation.getId()); } }
private Optional<String> getTranslationWithFallback(String locale, Key key) { for (String parentLocale : getParentLocalesFor(new ULocale(locale))) { if (key.isTranslated(parentLocale)) { return Optional.of(key.getTranslation(parentLocale).getValue()); } } if (i18nConfig.isTranslationFallback()) { String defaultLocale = localeService.getDefaultLocale(); if (key.isTranslated(defaultLocale)) { return Optional.of(key.getTranslation(defaultLocale).getValue()); } } return Optional.empty(); }
private void assembleDefaultTranslation(Key key, KeyRepresentation keyRepresentation, String defaultLocale) { if (key.isTranslated(defaultLocale)) { Translation translation = key.getTranslation(defaultLocale); keyRepresentation.setTranslation(translation.getValue()); keyRepresentation.setApprox(translation.isApproximate()); } else { keyRepresentation.setMissing(true); } } }
int translatedCount = 0; for (Key key : keys) { Translation translation = key.getTranslation(selectLocale .getId()); if (translation != null
private void addKeyWithTranslationsToFile(Key key, CSVRowWriter csvRowWriter) { for (String columnName : csvRowWriter.getColumnNames()) { if (isColumnKey(columnName)) { csvRowWriter.addColumnValue(I18nCSVTemplateLoader.KEY, key.getId()); } else { if (key.isTranslated(columnName)) { csvRowWriter.addColumnValue(columnName, key.getTranslation(columnName).getValue()); } } } }
private TranslationValueRepresentation assembleTranslation(Key key, String locale) { TranslationValueRepresentation source = new TranslationValueRepresentation(); source.setLocale(locale); Translation translation = key.getTranslation(locale); source.setTranslation(translation.getValue()); source.setApprox(translation.isApproximate()); source.setOutdated(translation.isOutdated()); return source; }