locale

Unicode character not in range when calling locale.strxfrm

本小妞迷上赌 提交于 2019-12-20 21:02:56
问题 I am experiencing an odd behavior when using the locale library with unicode input. Below is a minimum working example: >>> x = '\U0010fefd' >>> ord(x) 1113853 >>> ord('\U0010fefd') == 0X10fefd True >>> ord(x) <= 0X10ffff True >>> import locale >>> locale.strxfrm(x) '\U0010fefd' >>> locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') 'en_US.UTF-8' >>> locale.strxfrm(x) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: character U+110000 is not in range [U+0000; U

Unicode character not in range when calling locale.strxfrm

泄露秘密 提交于 2019-12-20 21:02:32
问题 I am experiencing an odd behavior when using the locale library with unicode input. Below is a minimum working example: >>> x = '\U0010fefd' >>> ord(x) 1113853 >>> ord('\U0010fefd') == 0X10fefd True >>> ord(x) <= 0X10ffff True >>> import locale >>> locale.strxfrm(x) '\U0010fefd' >>> locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') 'en_US.UTF-8' >>> locale.strxfrm(x) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: character U+110000 is not in range [U+0000; U

adding locale on server

假如想象 提交于 2019-12-20 10:28:02
问题 I am planning to use strftime() , however when I check my server regarding what's available locale, via (locale -a) , I only have this: C en_US.utf8 POSIX I badly need to have this de_DE.utf8 , in order to turn my dates to German. How can I add additional locale? Is there any other better way? 回答1: You need to generate de_DE.utf8 locale in your server. The process is pretty straightforward. For example on Debian/Ubuntu distros, you can add/remove locales by issuing the following command: sudo

How to get application language and device language separately in android?

断了今生、忘了曾经 提交于 2019-12-20 10:24:28
问题 My device language is in English and my application language is in Italian.So how I get the device language and application language programmatically ? 回答1: get system language Resources.getSystem().getConfiguration().locale.getLanguage(); get app language String CurrentLang = Locale.getDefault().getLanguage(); 回答2: This is the correct answer: getResources().getConfiguration().locale 回答3: To Get System Language Use this: String DeviceLang =Resources.getSystem().getConfiguration().locale

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

你离开我真会死。 提交于 2019-12-20 09:34:14
问题 I have an app that prints a calculated money value and I want to display that value with the default currency format. For example in Europe you would write: 1.000,95€ In the US I think you would write 1,000.95$ In other currencies there are more or less values displayed for the decimal fraction, in US it would be 2 but in Japan it would be 0. How can I obtain a exact as possible format for all existing currencies? 回答1: I found the solution. THe class NumberFormat has a multitude of predefined

Dynamically change locale for DatePipe in Angular 2

独自空忆成欢 提交于 2019-12-20 09:18:23
问题 I'm making an Angular project where the user has the ability to switch languages. Is it possible to make the locale dynamic? I have seen that you can add it in the NgModule but i'm guessing it's not dynamic when i put it there? Or can i change it somehow through a service or something? 回答1: Using providers you can change your default locale in your NgModule . to do this You need to import LOCALE_ID from angular/core and fetch your locale language to pass the same to providers. import { LOCALE

Why might Resources.getString() intermittently return strings from the wrong locale?

拜拜、爱过 提交于 2019-12-20 09:17:27
问题 I have an Android application with English strings in values/strings.xml. For each string in that file, I have an entry in values-ja/strings.xml with the Japanese translation of that string. If I set the emulator, a Nexus One or Nexus S to Japanese, the UI shows Japanese text throughout. Most of the time. Sometimes, some portion of the UI will appear in English, even though the current locale is ja-JP. For instance, I wrote this test code in the onCreate() method of one of my activities: Log

Why might Resources.getString() intermittently return strings from the wrong locale?

安稳与你 提交于 2019-12-20 09:13:09
问题 I have an Android application with English strings in values/strings.xml. For each string in that file, I have an entry in values-ja/strings.xml with the Japanese translation of that string. If I set the emulator, a Nexus One or Nexus S to Japanese, the UI shows Japanese text throughout. Most of the time. Sometimes, some portion of the UI will appear in English, even though the current locale is ja-JP. For instance, I wrote this test code in the onCreate() method of one of my activities: Log

What is a good definition for language code and locale codes?

北城以北 提交于 2019-12-20 08:48:52
问题 When to use en_GB and en-GB ? What is the difference ? Is there an ISO name for this ISO 639-1 (language) and ISO 3166 (country) combination ? 回答1: There are several systems for locale identifiers. Many of them are similar at the first glance, but not when you go deeper: Some examples (Serbian-Serbia with Latin Script, Japanese-Japan with radical sorting): UTS-35, ICU, Mac OS X, Flash: sr-Latn-RS, ja-JP@collation=radical Newer UTS-35, BCP 47 extension U: sr-Latn-RS, ja-JP-u-co-unihan Win 2000

Locale codes for iPhone lproj folders

这一生的挚爱 提交于 2019-12-20 08:03:26
问题 Where would I find a list of locale name abbreviations for my project localization folders? (Such as en for English, fr for French). I am looking to do German, Spanish and others. 回答1: You can just call them English.lproj , Spanish.lproj , etc. The "abbreviated names" are actually IETF language tags (i.e. BCP 47), except that you use pt_PT.lproj instead of pt-PT.lproj . The actual interpretation routine is in https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/PlugIn