Android get device locale

There’s a much simpler and cleaner way to do this than using reflection or parsing some system property. As you noticed once you set the default Locale in your app you don’t have access to the system default Locale any more. The default Locale you set in your app is valid only during the life … Read more

How to format a Float Value with the device currency format?

For sake of completeness suppose you want to display a price in phone’s current locale (correct decimal mark and thousand separator) but with a currency of your choice. NumberFormat format = NumberFormat.getCurrencyInstance(Locale.getDefault()); format.setCurrency(Currency.getInstance(“CZK”)); String result = format.format(1234567.89); result would then hold these values: CZK1,234,567.89 with US locale 1 234 567,89 Kč with Czech locale If … Read more

Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment

If you are trying to execute tests case you must set the following environment variables each time: export LC_ALL=en_US.utf-8 export LANG=en_US.utf-8 Doing this each time will resolve the error. It may also be possible to set this in your IDE run configuration as LC_ALL=en_US.UTF-8;LANG=en_US.UTF-8 For example see the following setting in PyCharm 2016:

Add ‘decimal-mark’ thousands separators to a number

If you want to add a thousands separator, you can write: >>> ‘{0:,}’.format(1000000) ‘1,000,000’ But it only works in Python 2.7 and above. See format string syntax. In older versions, you can use locale.format(): >>> import locale >>> locale.setlocale(locale.LC_ALL, ”) ‘en_AU.utf8’ >>> locale.format(‘%d’, 1000000, 1) ‘1,000,000’ the added benefit of using locale.format() is that it … Read more

SVN cannot set LC_CTYPE locale

Check the output of locale -a If the locale that SVN is complaining about isn’t installed, then you can install it. You might need to do for Debian or similar systems: sudo dpkg-reconfigure locales If you want to configure locales manually: sudo vim /etc/locale.gen # and add “en_US.UTF-8 UTF-8” sudo locale-gen Or if your locale-gen … Read more

Android App Bundle with in-app locale change

Edit: The PlayCore API now supports downloading the strings for another language on-demand: https://developer.android.com/guide/playcore/feature-delivery/on-demand#lang_resources Alternative solution (discouraged): You can disable the splitting by language by adding the following configuration in your build.gradle android { bundle { language { // Specifies that the app bundle should not support // configuration APKs for language resources. These // … Read more

How do I check if system is 12 or 24 hour?

Shouldn’t it be if (!DateFormat.is24HourFormat(this)) You want to assign am/pm only when it is not set to 24 hour format, right? Here is a more compact version: if (!DateFormat.is24HourFormat(this)) { mHour = mCalendar.get(Calendar.HOUR_OF_DAY); int hourOfDay = mHour; if (hourOfDay >= 12) { views.setTextViewText(R.id.AMPM, “pm”); } else { views.setTextViewText(R.id.AMPM, “am”); } } else { views.setTextViewText(R.id.AMPM, “”); … Read more

Is en_UK an illegal locale?

The correct country code is en_GB. Locales use ISO 3166-1 for country codes. The wikipedia writeup includes: The codes are chosen, according to the ISO 3166/MA, “to reflect the significant, unique component of the country name in order to allow a visual association between country name and country code”.[7] For this reason, common components of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)