public boolean isTranslated(String locale) { return translations.get(new TranslationId(entityId, locale)) != null; }
private void addTranslation(Map<String, Translation> translations, Key key, String locale) { Translation source = this.translations.get(locale); if (source == null) { source = new Translation(new TranslationId(key.entityId, locale), key, "", false, false); } translations.put(locale, source); }
private Translation createOrUpdateTranslation(String locale, String value, boolean isApproximate) { Translation translation; if (isTranslated(locale)) { translation = this.translations.get(new TranslationId(entityId, locale)); translation.updateValue(value); } else { translation = new Translation(new TranslationId(entityId, locale), value); } translation.setApproximate(isApproximate); translations.put(new TranslationId(entityId, locale), translation); return translation; }
/** * Saves or updates the translation for the specified locale. * If the key was outdated, checks if the key is still outdated. * * @param locale specified the translation locale * @param value translation value * @param approximate translation approximate indicator * @param outdated translation outdated indicator * @throws java.lang.IllegalArgumentException if locale is blank */ public void addTranslation(String locale, String value, boolean approximate, boolean outdated) { Preconditions.checkArgument(StringUtils.isNotBlank(locale)); // If exists, get the translation for the given locale Translation translation = this.translations.get(locale); if (translation == null) { translation = new Translation(); translation.setEntityId(new TranslationId(entityId, locale)); } translation.setValue(value); translation.setApproximate(approximate); translation.setOutdated(outdated); translation.setKey(this); translations.put(locale, translation); updateOutdated(); }