IDEMPIERE-2003 Capturing wrong numbers with numeric keypad when decimal separator is not dot / fix a problem with same language using different separator in different countries, for example es_CO vs es_SV

This commit is contained in:
Carlos Ruiz 2019-01-17 20:51:48 +01:00
parent d7065224fa
commit 4d9912c6e3
4 changed files with 46 additions and 28 deletions

View File

@ -355,7 +355,7 @@ public final class DisplayType
{
Language myLanguage = language;
if (myLanguage == null)
myLanguage = Language.getLoginLanguage();
myLanguage = Env.getLocaleLanguage(Env.getCtx());
Locale locale = myLanguage.getLocale();
DecimalFormat format = null;
if (locale != null)

View File

@ -37,6 +37,7 @@ import java.util.Date;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
@ -1144,6 +1145,45 @@ public final class Env
return Language.getLoginLanguage();
} // getLanguage
/**
* @param ctx
* @return Language
*/
public static Language getLocaleLanguage(Properties ctx) {
Locale locale = getLocale(ctx);
Language language = Env.getLanguage(ctx);
if (!language.getLocale().equals(locale)) {
Language tmp = Language.getLanguage(locale.toString());
String adLanguage = language.getAD_Language();
language = new Language(tmp.getName(), adLanguage, tmp.getLocale(), tmp.isDecimalPoint(),
tmp.getDateFormat().toPattern(), tmp.getMediaSize());
}
return language;
}
public static final String LOCALE = "#Locale";
/**
* @param ctx
* @return Locale
*/
public static Locale getLocale(Properties ctx) {
String value = Env.getContext(ctx, Env.LOCALE);
Locale locale = null;
if (value != null && value.length() > 0)
{
String[] components = value.split("\\_");
String language = components.length > 0 ? components[0] : "";
String country = components.length > 1 ? components[1] : "";
locale = new Locale(language, country);
}
else
{
locale = Env.getLanguage(ctx).getLocale();
}
return locale;
}
public static ArrayList<String> getSupportedLanguages()
{
ArrayList<String> AD_Languages = new ArrayList<String>();

View File

@ -90,7 +90,7 @@ import com.itextpdf.text.pdf.PdfWriter;
*/
public final class AEnv
{
public static final String LOCALE = "#Locale";
public static final String LOCALE = Env.LOCALE;
/**
* Show in the center of the screen.
@ -663,15 +663,7 @@ public final class AEnv
* @return Language
*/
public static Language getLanguage(Properties ctx) {
Locale locale = getLocale(ctx);
Language language = Env.getLanguage(ctx);
if (!language.getLocale().equals(locale)) {
Language tmp = Language.getLanguage(locale.toString());
String adLanguage = language.getAD_Language();
language = new Language(tmp.getName(), adLanguage, tmp.getLocale(), tmp.isDecimalPoint(),
tmp.getDateFormat().toPattern(), tmp.getMediaSize());
}
return language;
return Env.getLocaleLanguage(ctx);
}
/**
@ -679,21 +671,7 @@ public final class AEnv
* @return Locale
*/
public static Locale getLocale(Properties ctx) {
String value = Env.getContext(ctx, AEnv.LOCALE);
Locale locale = null;
if (value != null && value.length() > 0)
{
String[] components = value.split("\\_");
String language = components.length > 0 ? components[0] : "";
String country = components.length > 1 ? components[1] : "";
locale = new Locale(language, country);
}
else
{
locale = Env.getLanguage(ctx).getLocale();
}
return locale;
return Env.getLocale(ctx);
}
/**

View File

@ -91,7 +91,7 @@ public class NumberBox extends Div
decimalBox.setSclass("editor-input");
decimalBox.setId(decimalBox.getUuid());
char separatorChar = DisplayType.getNumberFormat(DisplayType.Number, Env.getLanguage(Env.getCtx())).getDecimalFormatSymbols().getDecimalSeparator();
char separatorChar = DisplayType.getNumberFormat(DisplayType.Number, null).getDecimalFormatSymbols().getDecimalSeparator();
String separator = Character.toString(separatorChar);
boolean processDotKeypad = MSysConfig.getBooleanValue(MSysConfig.ZK_DECIMALBOX_PROCESS_DOTKEYPAD, true, Env.getAD_Client_ID(Env.getCtx()));
if (processDotKeypad) {
@ -253,7 +253,7 @@ public class NumberBox extends Div
Vbox vbox = new Vbox();
char separatorChar = DisplayType.getNumberFormat(DisplayType.Number, Env.getLanguage(Env.getCtx())).getDecimalFormatSymbols().getDecimalSeparator();
char separatorChar = DisplayType.getNumberFormat(DisplayType.Number, null).getDecimalFormatSymbols().getDecimalSeparator();
String separator = Character.toString(separatorChar);
txtCalc = new Textbox();