Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of Locale with Region / Country #58

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ public class AppFilter implements Filter {

private static Locale APP_LOCALE;

private static Locale getLocaleByTag(String tag) {
return Locale.forLanguageTag(tag.replaceAll("\\_", "-"));
}

@Override
public void init(FilterConfig filterConfig) throws ServletException {
try {
final String appLocale = AppSettings.get().get(AvailableAppSettings.APPLICATION_LOCALE, null);
APP_LOCALE = appLocale == null ? null : new Locale(appLocale);
APP_LOCALE = appLocale == null ? null : getLocaleByTag(appLocale);
} catch (Exception e) {
}
}
Expand All @@ -57,7 +61,7 @@ public static String getBaseURL() {
public static Locale getLocale() {
User user = AuthUtils.getUser();
if (user != null && user.getLanguage() != null) {
return new Locale(user.getLanguage());
return getLocaleByTag(user.getLanguage());
}
if (user != null && APP_LOCALE != null) {
return APP_LOCALE;
Expand Down
2 changes: 1 addition & 1 deletion axelor-core/src/main/java/com/axelor/i18n/I18nBundle.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private synchronized Map<String, String> doLoad() {
return messages;
}

final String lang = locale.getLanguage();
final String lang = locale.toString().toLowerCase();
final Query<MetaTranslation> query =
Query.of(MetaTranslation.class)
.filter("self.language = :lang AND self.message IS NOT NULL")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private void process(InputStream stream, String fileName) throws IOException {
return;
}

language = matcher.group(1);
language = matcher.group(1).toLowerCase();

try (Reader reader = new InputStreamReader(stream, Charsets.UTF_8);
CSVReader csvReader =
Expand Down