@Override public String getMessage(String code, String language, String arg1, String arg2, String arg3) { final Locale locale = localeManagerFactory.parseLocale(language); return messageSource.getMessage(code, new Object[] {arg1, arg2, arg3}, locale); }
@Override public String getMessage(String code, String language) { final Locale locale = localeManagerFactory.parseLocale(language); final String message = messageSource.getMessage(code, null, locale); return message; }
@Override public String getMessage(String code, String language, String arg1) { final Locale locale = localeManagerFactory.parseLocale(language); return messageSource.getMessage(code, new Object[] {arg1}, locale); }
@Override public String getMessage(String code, String language, String arg1, String arg2, String arg3) { final Locale locale = localeManagerFactory.parseLocale(language); return messageSource.getMessage(code, new Object[] {arg1, arg2, arg3}, locale); }
@Override public String getMessage(String code, String language, String arg1, String arg2) { final Locale locale = localeManagerFactory.parseLocale(language); return messageSource.getMessage(code, new Object[] {arg1, arg2}, locale); }
@Override public String getMessage(String code, String language) { final Locale locale = localeManagerFactory.parseLocale(language); final String message = messageSource.getMessage(code, null, locale); return message; }
@Override public String getMessage(String code, String language, String arg1) { final Locale locale = localeManagerFactory.parseLocale(language); return messageSource.getMessage(code, new Object[] {arg1}, locale); }
@Override public String getMessage(String code, String language, String arg1, String arg2) { final Locale locale = localeManagerFactory.parseLocale(language); return messageSource.getMessage(code, new Object[] {arg1, arg2}, locale); }
/** * This method checks whether id indicates that it is a layout owner's structure element (or at * least derived from it). If it is the case, then it asks {@link MessageSource} to resolve the * message using layout element's name. Otherwise it returns the name. Note that layout owner's * element identifier format is 'uXlYnZ' where X stands for layout owners id, Y stands for * layout id, and Z stands for element (node) identifier, hence identifiers that start with 'u' * are considered as derived from layout owner. * * @param id - layout structure element's identifier. * @param language - locale identifier. * @param name - default layout strucute element's name. * @return localized title in case of layout owner's element or default name otherwise. */ public static String getTitle(String id, String language, String name) { if (id != null && id.startsWith(Constants.FRAGMENT_ID_USER_PREFIX)) { final Locale locale = localeManagerFactory.parseLocale(language); return messageSource.getMessage(name, new Object[] {}, name, locale); } return name; } }
/** * This method checks whether id indicates that it is a layout owner's structure element (or at * least derived from it). If it is the case, then it asks {@link MessageSource} to resolve the * message using layout element's name. Otherwise it returns the name. Note that layout owner's * element identifier format is 'uXlYnZ' where X stands for layout owners id, Y stands for * layout id, and Z stands for element (node) identifier, hence identifiers that start with 'u' * are considered as derived from layout owner. * * @param id - layout structure element's identifier. * @param language - locale identifier. * @param name - default layout strucute element's name. * @return localized title in case of layout owner's element or default name otherwise. */ public static String getTitle(String id, String language, String name) { if (id != null && id.startsWith(Constants.FRAGMENT_ID_USER_PREFIX)) { final Locale locale = localeManagerFactory.parseLocale(language); return messageSource.getMessage(name, new Object[] {}, name, locale); } return name; } }
/** * Populate <code>portalLocales</code> from a comma-delimited locale string list, e.g. * "en_US,ja_JP" */ @PostConstruct public void init() { logger.info("Using localeAware={}", localeAware); logger.info("Using portalLocalesProperty='{}'", portalLocalesProperty); if (StringUtils.isNotBlank(portalLocalesProperty)) { final List<Locale> list = new ArrayList<>(); for (String token : portalLocalesProperty.split(",")) { list.add(parseLocale(token.trim())); } portalLocales = Collections.unmodifiableList(list); logger.info("Loaded the following portalLocales: {}", portalLocales); } }
/** * Populate <code>portalLocales</code> from a comma-delimited locale string list, e.g. * "en_US,ja_JP" */ @PostConstruct public void init() { logger.info("Using localeAware={}", localeAware); logger.info("Using portalLocalesProperty='{}'", portalLocalesProperty); if (StringUtils.isNotBlank(portalLocalesProperty)) { final List<Locale> list = new ArrayList<>(); for (String token : portalLocalesProperty.split(",")) { list.add(parseLocale(token.trim())); } portalLocales = Collections.unmodifiableList(list); logger.info("Loaded the following portalLocales: {}", portalLocales); } }
@ResourceMapping @RequestMapping(params = "action=getEntity") public ModelAndView getEntity( @RequestParam("id") String code, @RequestParam("locale") String localeStr) { final Locale locale = localeManagerFactory.parseLocale(localeStr); final Message message = messageDao.getMessage(code, locale); return new ModelAndView("json", "message", message); }
@Override public Locale[] doInConnection(Connection con) throws SQLException, DataAccessException { final List<Locale> localeList = new ArrayList<Locale>(); final String query = "SELECT * FROM UP_USER_LOCALE WHERE USER_ID=? ORDER BY PRIORITY"; final PreparedStatement pstmt = con.prepareStatement(query); try { pstmt.clearParameters(); pstmt.setInt(1, person.getID()); logger.debug(query); final ResultSet rs = pstmt.executeQuery(); try { while (rs.next()) { final String localeString = rs.getString("LOCALE"); final Locale locale = localeManagerFactory.parseLocale(localeString); localeList.add(locale); } } finally { rs.close(); } } finally { pstmt.close(); } return localeList.toArray(new Locale[localeList.size()]); } });
@Override public Locale[] doInConnection(Connection con) throws SQLException, DataAccessException { final List<Locale> localeList = new ArrayList<Locale>(); final String query = "SELECT * FROM UP_USER_LOCALE WHERE USER_ID=? ORDER BY PRIORITY"; final PreparedStatement pstmt = con.prepareStatement(query); try { pstmt.clearParameters(); pstmt.setInt(1, person.getID()); logger.debug(query); final ResultSet rs = pstmt.executeQuery(); try { while (rs.next()) { final String localeString = rs.getString("LOCALE"); final Locale locale = localeManagerFactory.parseLocale(localeString); localeList.add(locale); } } finally { rs.close(); } } finally { pstmt.close(); } return localeList.toArray(new Locale[localeList.size()]); } });
@ResourceMapping @RequestMapping(params = "action=postTranslation") public ModelAndView postTranslation( @RequestParam("id") String code, @RequestParam("locale") String localeStr, @RequestParam("value") String value) { final Locale locale = localeManagerFactory.parseLocale(localeStr); if (locale != null && StringUtils.hasText(code) && StringUtils.hasText(value)) { final Message message = messageDao.getMessage(code, locale); if (message != null) { message.setValue(value); messageDao.updateMessage(message); } else { // if message is not found in the backend storage, a new one must be created messageDao.createMessage(code, locale, value); } } return new ModelAndView("json"); } }
Locale userLocale = localeManagerFactory.parseLocale(localeString); List<Locale> locales = Collections.singletonList(userLocale);