use of org.mifos.config.LocaleSetting in project head by mifos.
the class MifosInternationalizedHtmlTag method renderHtmlStartElement.
/**
* Renders an <html> element with appropriate language attributes.
* @since Struts 1.2
*/
@Override
protected String renderHtmlStartElement() {
StringBuffer sb = new StringBuffer("<html");
Locale locale = ApplicationContextProvider.getBean(PersonnelServiceFacade.class).getUserPreferredLocale();
String languageCode = locale.getLanguage();
String countryCode = locale.getCountry();
LocaleSetting configLocale = new LocaleSetting();
String direction = configLocale.getDirection();
setLocaleIntoHttpSession(languageCode, countryCode);
boolean validLanguage = ((languageCode != null) && (languageCode.length() > 0));
boolean validCountry = countryCode.length() > 0;
if (this.xhtml) {
this.pageContext.setAttribute(Globals.XHTML_KEY, "true", PageContext.PAGE_SCOPE);
sb.append(" xmlns=\"http://www.w3.org/1999/xhtml\"");
}
if ((this.lang || this.locale || this.xhtml) && validLanguage) {
sb.append(" lang=\"");
appendLangIfCountryIsValid(sb, languageCode, countryCode, validCountry);
}
if (this.xhtml && validLanguage) {
sb.append(" xml:lang=\"");
appendLangIfCountryIsValid(sb, languageCode, countryCode, validCountry);
}
appendLang(sb, languageCode);
setDirection(sb, languageCode, direction);
sb.append(">");
return sb.toString();
}
use of org.mifos.config.LocaleSetting in project head by mifos.
the class ViewOrganizationSettingsServiceFacadeWebTier method getLocaleInfo.
private Properties getLocaleInfo() {
LocaleSetting configLocale = new LocaleSetting();
Properties localeInfo = new Properties();
localeInfo.setProperty("localeCountryCode", configLocale.getCountryCode());
localeInfo.setProperty("localeLanguageCode", configLocale.getLanguageCode());
localeInfo.setProperty("localeDirection", configLocale.getDirection());
return localeInfo;
}
use of org.mifos.config.LocaleSetting in project head by mifos.
the class StandardTestingService method setLocale.
@Override
public void setLocale(String languageCode, String countryCode) throws MifosException {
try {
LocaleSetting configLocale = new LocaleSetting();
configLocale.setLanguageCode(languageCode);
configLocale.setCountryCode(countryCode);
Localization localization = Localization.getInstance();
localization.setConfigLocale(configLocale);
if (SecurityContextHolder.getContext() != null) {
if (SecurityContextHolder.getContext().getAuthentication() != null) {
if (SecurityContextHolder.getContext().getAuthentication().getPrincipal() != null) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
user.setPreferredLocaleId(Localization.getInstance().getLocaleId(Localization.getInstance().getConfiguredLocale()));
}
}
}
StaticHibernateUtil.startTransaction();
PersonnelBO p = (PersonnelBO) StaticHibernateUtil.getSessionTL().get(PersonnelBO.class, (short) 1);
p.setPreferredLocale(Localization.getInstance().getConfiguredLocaleId());
StaticHibernateUtil.getSessionTL().update(p);
StaticHibernateUtil.commitTransaction();
MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
configMgr.setProperty("Localization.LanguageCode", languageCode);
configMgr.setProperty("Localization.CountryCode", countryCode);
} catch (MifosRuntimeException e) {
throw new MifosException("The locale " + languageCode + "_" + countryCode + " is not supported by Mifos.");
}
}
use of org.mifos.config.LocaleSetting in project head by mifos.
the class ApplicationInitializer method setAttributesOnContext.
public void setAttributesOnContext(ServletContext servletContext) throws TaskSystemException {
// FIXME: replace with Spring-managed beans
final MifosScheduler mifosScheduler = new MifosScheduler();
final ShutdownManager shutdownManager = new ShutdownManager();
Configuration.getInstance();
configureAuditLogValues(Localization.getInstance().getConfiguredLocale());
LocaleSetting configLocale = new LocaleSetting();
@SuppressWarnings("deprecation") final UserLocale userLocale = new UserLocale(ApplicationContextProvider.getBean(PersonnelServiceFacade.class));
if (servletContext != null) {
mifosScheduler.initialize();
servletContext.setAttribute(MifosScheduler.class.getName(), mifosScheduler);
servletContext.setAttribute(ShutdownManager.class.getName(), shutdownManager);
servletContext.setAttribute(LocaleSetting.class.getSimpleName(), configLocale);
servletContext.setAttribute(UserLocale.class.getSimpleName(), userLocale);
}
}
Aggregations