use of com.codename1.l10n.L10NManager in project CodenameOne by codenameone.
the class AndroidImplementation method getLocalizationManager.
/**
* @inheritDoc
*/
public L10NManager getLocalizationManager() {
if (l10n == null) {
Locale l = Locale.getDefault();
l10n = new L10NManager(l.getLanguage(), l.getCountry()) {
public double parseDouble(String localeFormattedDecimal) {
try {
return NumberFormat.getNumberInstance().parse(localeFormattedDecimal).doubleValue();
} catch (ParseException err) {
return Double.parseDouble(localeFormattedDecimal);
}
}
public String format(int number) {
return NumberFormat.getNumberInstance().format(number);
}
public String format(double number) {
return NumberFormat.getNumberInstance().format(number);
}
public String formatCurrency(double currency) {
return NumberFormat.getCurrencyInstance().format(currency);
}
public String formatDateLongStyle(Date d) {
return DateFormat.getDateInstance(DateFormat.LONG).format(d);
}
public String formatDateShortStyle(Date d) {
return DateFormat.getDateInstance(DateFormat.SHORT).format(d);
}
public String formatDateTime(Date d) {
return DateFormat.getDateTimeInstance().format(d);
}
public String formatDateTimeMedium(Date d) {
DateFormat dd = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
return dd.format(d);
}
public String formatDateTimeShort(Date d) {
DateFormat dd = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
return dd.format(d);
}
public String getCurrencySymbol() {
return NumberFormat.getInstance().getCurrency().getSymbol();
}
public void setLocale(String locale, String language) {
super.setLocale(locale, language);
Locale l = new Locale(language, locale);
Locale.setDefault(l);
}
};
}
return l10n;
}
use of com.codename1.l10n.L10NManager in project CodenameOne by codenameone.
the class IOSImplementation method getLocalizationManager.
/**
* @inheritDoc
*/
public L10NManager getLocalizationManager() {
if (l10n == null) {
Locale l = Locale.getDefault();
l10n = new L10NManager(l.getLanguage(), l.getCountry()) {
public String format(int number) {
return nativeInstance.formatInt(number);
}
public String format(double number) {
return nativeInstance.formatDouble(number);
}
public String formatCurrency(double currency) {
return nativeInstance.formatCurrency(currency);
}
public String formatDateLongStyle(Date d) {
return nativeInstance.formatDate(d.getTime());
}
public String formatDateShortStyle(Date d) {
return nativeInstance.formatDateShort(d.getTime());
}
public String formatDateTime(Date d) {
return nativeInstance.formatDateTime(d.getTime());
}
public double parseDouble(String localeFormattedDecimal) {
return nativeInstance.parseDouble(localeFormattedDecimal);
}
public String formatDateTimeMedium(Date d) {
return nativeInstance.formatDateTimeMedium(d.getTime());
}
public String formatDateTimeShort(Date d) {
return nativeInstance.formatDateTimeShort(d.getTime());
}
public String getCurrencySymbol() {
return nativeInstance.getCurrencySymbol();
}
public void setLocale(String locale, String language) {
super.setLocale(locale, language);
Locale l = new Locale(language, locale);
Locale.setDefault(l);
nativeInstance.setLocale(language + "_" + locale);
}
};
}
return l10n;
}
use of com.codename1.l10n.L10NManager in project CodenameOne by codenameone.
the class JavaSEPort method getLocalizationManager.
/**
* @inheritDoc
*/
public L10NManager getLocalizationManager() {
if (l10n == null) {
Locale l = Locale.getDefault();
l10n = new L10NManager(l.getLanguage(), l.getCountry()) {
public double parseDouble(String localeFormattedDecimal) {
try {
return NumberFormat.getNumberInstance().parse(localeFormattedDecimal).doubleValue();
} catch (ParseException err) {
return Double.parseDouble(localeFormattedDecimal);
}
}
public String format(int number) {
return NumberFormat.getNumberInstance().format(number);
}
public String format(double number) {
return NumberFormat.getNumberInstance().format(number);
}
public String formatCurrency(double currency) {
return NumberFormat.getCurrencyInstance().format(currency);
}
public String formatDateLongStyle(Date d) {
return DateFormat.getDateInstance(DateFormat.LONG).format(d);
}
public String formatDateShortStyle(Date d) {
return DateFormat.getDateInstance(DateFormat.SHORT).format(d);
}
public String formatDateTime(Date d) {
return DateFormat.getDateTimeInstance().format(d);
}
public String formatDateTimeMedium(Date d) {
DateFormat dd = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
return dd.format(d);
}
public String formatDateTimeShort(Date d) {
DateFormat dd = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
return dd.format(d);
}
public String getCurrencySymbol() {
return NumberFormat.getInstance().getCurrency().getSymbol();
}
public void setLocale(String locale, String language) {
super.setLocale(locale, language);
Locale l = new Locale(language, locale);
Locale.setDefault(l);
}
};
}
return l10n;
}
use of com.codename1.l10n.L10NManager in project CodenameOne by codenameone.
the class GameCanvasImplementation method getLocalizationManager.
/**
* @inheritDoc
*/
public L10NManager getLocalizationManager() {
if (lm == null) {
String l = System.getProperty("microedition.locale");
String lang = "en";
String country = "US";
if (l != null && l.length() >= 5) {
lang = l.substring(0, 2);
country = l.substring(3, 5);
}
lm = new L10NManager(lang, country) {
public String format(int number) {
return super.format(number);
}
public String format(double number) {
return super.format(number);
}
public String formatCurrency(double currency) {
return super.formatCurrency(currency);
}
public String formatDateLongStyle(Date d) {
return super.formatDateLongStyle(d);
}
public String formatDateShortStyle(Date d) {
return super.formatDateShortStyle(d);
}
public String formatDateTime(Date d) {
return super.formatDateTime(d);
}
public String getCurrencySymbol() {
return super.getCurrencySymbol();
}
};
}
return lm;
}
use of com.codename1.l10n.L10NManager in project CodenameOne by codenameone.
the class BlackBerryImplementation method getLocalizationManager.
/**
* @inheritDoc
*/
public L10NManager getLocalizationManager() {
if (l10n == null) {
Locale l = Locale.getDefault();
l10n = new L10NManager(l.getLanguage(), l.getCountry()) {
public String format(int number) {
return super.format(number);
}
public String format(double number) {
return super.format(number);
}
public String formatCurrency(double currency) {
return super.formatCurrency(currency);
}
public String formatDateLongStyle(Date d) {
return DateFormat.getInstance(DateFormat.DATE_LONG).format(d);
}
public String formatDateShortStyle(Date d) {
return DateFormat.getInstance(DateFormat.DATE_SHORT).format(d);
}
public String formatDateTime(Date d) {
String date = DateFormat.getInstance(DateFormat.DATE_FULL).format(d);
String time = DateFormat.getInstance(DateFormat.TIME_FULL).format(d);
return date + " " + time;
}
public String getCurrencySymbol() {
return super.getCurrencySymbol();
}
public void setLocale(String locale, String language) {
super.setLocale(locale, language);
Locale.setDefault(Locale.get(language, locale));
}
};
}
return l10n;
}
Aggregations