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

Support for languages with country variation. #57

Open
kaoecoito opened this issue Jul 21, 2019 · 1 comment
Open

Support for languages with country variation. #57

kaoecoito opened this issue Jul 21, 2019 · 1 comment

Comments

@kaoecoito
Copy link

Hello,

I started some tests with Axelor and I think it's an incredible product.
As a first step to use it in my country, Brazil, I went to check what it would take to create the translation into Brazilian Portuguese.
Axelor has support for Portuguese in the European variant but it is quite different from the Brazilian Portuguese and we have great difficulty understanding the European Portuguese, so the translation is an important step for use here in Brazil.

Studying the Axelor development kit I checked how the i18n files are loaded into the database and the way they are used later in the bundle and the locale definition.

I realized that the definition of the locale could generate a problem for the portguês brazil, or other locales that use the Region / Country.

The acronyms of locale with country follow a pt_BR or pt-BR format (IETF BCP 47)

The initialization of these locales in java should be done following the calls as an example in pt_BR.

Locale locale = new Locale ("pt", "BR");

or in the case of IETF BCP 47

Locale locale = Locale.forLanguageTag(“pt-BR");

In Axelor core AppFilter the locale is initialized always in constructor.

https://github.com/axelor/axelor-development-kit/blob/b41fc083ed10a348ce7fba0f60aaf6e8486f3640/axelor-core/src/main/java/com/axelor/app/internal/AppFilter.java#L47

https://github.com/axelor/axelor-development-kit/blob/b41fc083ed10a348ce7fba0f60aaf6e8486f3640/axelor-core/src/main/java/com/axelor/app/internal/AppFilter.java#L59

This way if the language is set with the country variant as "pt_br" the call would look like this.

Locale locale = new Locale (“pt_br");

Although this call does not generate errors for the java it does not load this locale in a valid way and starts to treat the definition as locale “en" for all cases of formatting, for example of dates and values.

So as a first step to allow correct use in languages ​​that include country code must be made adjustments in this code.

Also the class I18nBundle attempts to localize the translation using locale.getLanguage(), in the case of a properly initialized locale this method will return only the language code and not the country code.

this way I suggest the exchange of the call

https://github.com/axelor/axelor-development-kit/blob/b41fc083ed10a348ce7fba0f60aaf6e8486f3640/axelor-core/src/main/java/com/axelor/i18n/I18nBundle.java#L83

by the call

final String lang = locale.toString().toLowerCase();

The locale's toString() call would return "pt_BR" in locale cases with country and only "pt" in cases where they have not set the country code. The call to toLowerCase would be useful because postgres, for example, makes case-sensitive queries.

@modeware
Copy link

modeware commented Mar 2, 2020

Hi,
Can you explain how can I put the blue buttons inside a dropdown. How are they being created inside axelor's codebase? I am a beginner and if I have posed this question in a wrong place, please let me know.

Screenshot_2020-03-02_17-23-09

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants