TranslationConfiguration.java 2.99 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.granite.translation.api.TranslationManager
 *  org.apache.commons.lang3.StringUtils
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.adobe.cq.wcm.translation.impl;

import com.adobe.cq.wcm.translation.impl.TranslationPropertyType;
import com.adobe.granite.translation.api.TranslationManager;
import java.util.Set;
import java.util.TreeSet;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TranslationConfiguration {
    private static final Logger log = LoggerFactory.getLogger(TranslationConfiguration.class);
    private String srcLang = "";
    private String dstLang = "";
    private Set<String> propertiesToTranslate = new TreeSet<String>();
    private Set<String> propertiesWithLanguageCode = new TreeSet<String>();
    private Set<String> propertiesWithLanguagePath = new TreeSet<String>();
    TranslationManager translationManager;

    public void addPropertyToTranslate(String strProperty) {
        log.debug("FUNCTION: addPropertyToTranslate");
        if (!StringUtils.isEmpty((CharSequence)strProperty)) {
            this.propertiesToTranslate.add(strProperty);
        }
    }

    public void setSourceLanguage(String srcLang) {
        this.srcLang = srcLang;
    }

    public void setDestinationLanguage(String dstLang) {
        this.dstLang = dstLang;
    }

    public void setTranslationManager(TranslationManager tm) {
        log.debug("FUNCTION: setTranslationManager ", (Object)tm.getClass().getName());
        this.translationManager = tm;
    }

    public TranslationManager getTranslationManager() {
        log.debug("FUNCTION: getTranslationManager ", (Object)this.translationManager.getClass().getName());
        return this.translationManager;
    }

    public String getSourceLanguage() {
        return this.srcLang;
    }

    public String getDestinationLanguage() {
        return this.dstLang;
    }

    public void addPropertyWithLanguageCode(String strProperty) {
        if (!StringUtils.isEmpty((CharSequence)strProperty)) {
            this.propertiesWithLanguageCode.add(strProperty);
        }
    }

    public void addPropertyWithLanguagePath(String strProperty) {
        if (!StringUtils.isEmpty((CharSequence)strProperty)) {
            this.propertiesWithLanguagePath.add(strProperty);
        }
    }

    public TranslationPropertyType getTranslationPropertyType(String strPropertyName) {
        TranslationPropertyType propType = TranslationPropertyType.UNDEFINED;
        if (this.propertiesToTranslate.contains(strPropertyName)) {
            propType = TranslationPropertyType.TRANSLATETEXT;
        } else if (this.propertiesWithLanguageCode.contains(strPropertyName)) {
            propType = TranslationPropertyType.CONVERTLANGUAGE;
        } else if (this.propertiesWithLanguagePath.contains(strPropertyName)) {
            propType = TranslationPropertyType.CHANGEPATH;
        }
        return propType;
    }
}