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;
}
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;
}
Aggregations