Search in sources :

Example 1 with Language

use of org.eclipse.mylyn.docs.epub.dc.Language in project mylyn.docs by eclipse.

the class Publication method addLanguage.

/**
 * Adds a new language specification to the publication.
 *
 * @param id
 *            identifier or <code>null</code>
 * @param lang
 *            the RFC-3066 format of the language code or <code>null</code>
 * @return the language instance
 */
public Language addLanguage(String id, String value) {
    if (value == null) {
        // $NON-NLS-1$
        throw new IllegalArgumentException("A value must be specified");
    }
    Language dc = DCFactory.eINSTANCE.createLanguage();
    setDcCommon(dc, id, value);
    opfPackage.getMetadata().getLanguages().add(dc);
    return dc;
}
Also used : Language(org.eclipse.mylyn.docs.epub.dc.Language)

Example 2 with Language

use of org.eclipse.mylyn.docs.epub.dc.Language in project mylyn.docs by eclipse.

the class PublicationProxy method getLanguage.

@SuppressWarnings("rawtypes")
public String getLanguage() {
    EList<Language> languages = publication.getPackage().getMetadata().getLanguages();
    if (languages.size() > 0) {
        FeatureMap fm = languages.get(0).getMixed();
        Object o = fm.get(TEXT, false);
        if (o instanceof FeatureEList) {
            if (((FeatureEList) o).size() > 0) {
                String iso639 = ((FeatureEList) o).get(0).toString();
                Locale l = new Locale(iso639);
                return l.getDisplayLanguage();
            }
        }
    }
    return EMPTY_STRING;
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) FeatureEList(org.eclipse.emf.ecore.util.FeatureMapUtil.FeatureEList) Locale(java.util.Locale) Language(org.eclipse.mylyn.docs.epub.dc.Language)

Aggregations

Language (org.eclipse.mylyn.docs.epub.dc.Language)2 Locale (java.util.Locale)1 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)1 FeatureEList (org.eclipse.emf.ecore.util.FeatureMapUtil.FeatureEList)1