use of org.hisp.dhis.i18n.locale.I18nLocale in project dhis2-core by dhis2.
the class RemoveLocaleAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
try {
I18nLocale i18nLocale = localeService.getI18nLocale(id);
localeService.deleteI18nLocale(i18nLocale);
} catch (DeleteNotAllowedException ex) {
if (ex.getErrorCode().equals(DeleteNotAllowedException.ERROR_ASSOCIATED_BY_OTHER_OBJECTS)) {
message = i18n.getString("object_not_deleted_associated_by_objects") + " " + ex.getMessage();
return ERROR;
}
}
return SUCCESS;
}
use of org.hisp.dhis.i18n.locale.I18nLocale in project dhis2-core by dhis2.
the class DefaultI18nLocaleService method getAllLocales.
@Override
public List<Locale> getAllLocales() {
List<Locale> locales = new ArrayList<>();
for (I18nLocale locale : localeStore.getAll()) {
locales.add(LocaleUtils.getLocale(locale.getLocale()));
}
Collections.sort(locales, LocaleNameComparator.INSTANCE);
return locales;
}
use of org.hisp.dhis.i18n.locale.I18nLocale in project dhis2-core by dhis2.
the class DefaultI18nLocaleService method addI18nLocale.
@Override
public boolean addI18nLocale(String language, String country) {
String languageName = languages.get(language);
String countryName = countries.get(country);
if (language == null || languageName == null) {
// Language is required
return false;
}
if (country != null && countryName == null) {
// Country not valid
return false;
}
String localeStr = LocaleUtils.getLocaleString(language, country, null);
Locale locale = LocaleUtils.getLocale(localeStr);
I18nLocale i18nLocale = new I18nLocale(locale);
saveI18nLocale(i18nLocale);
return true;
}
use of org.hisp.dhis.i18n.locale.I18nLocale in project dhis2-core by dhis2.
the class I18nLocalePopulator method executeInTransaction.
@Override
public void executeInTransaction() {
int count = localeService.getI18nLocaleCount();
if (count > 0) {
return;
}
for (String locale : DEFAULT_LOCALES) {
localeService.saveI18nLocale(new I18nLocale(new Locale(locale)));
}
log.info("Populated default locales");
}
Aggregations