iOS Language and region judgments

Source: Internet
Author: User

Nslocale *local = [Nslocale Currentlocale];
if (![ Local.currencycode isequaltostring:@ "CNY"]) {}//Region currency code. Note that CurrencyCode can only be used in iOS 10 and later, so it will be crash on systems below this version.

You can use the following judgment:

Current location information, including language and region

NSString *identifier = [[nslocale currentlocale] localeidentifier];

nsstring *displayname = [[nslocale currentlocale] displaynameforkey: Nslocaleidentifier value: identifier];

If (![ DisplayName isequaltostring:@ " Chinese (China)"]) {}

Language of use at the current location

Nslocale *currentlocale = [Nslocale Currentlocale];

NSLog (@ "Language Code is%@", [Currentlocale Objectforkey:nslocalelanguagecode]);

System language

nsarray *arlanguages = [[nsuserdefaults standarduserdefaults] objectforkey:@ " Applelanguages "];

nsstring *strlang = [arlanguages objectatindex:0];

Language is Simplified Chinese:

2017-09-18 10:50:23.517 ceshi[2343:854583] Chinese (China)
2017-09-18 10:50:23.521 ceshi[2343:854583] Languagecode is en
2017-09-18 10:50:23.521 ceshi[2343:854583] Applelanguages:zh-hans-cn

Language is 中文版:

2017-09-18 11:08:51.587 ceshi[2396:860809] 中文版 (China)
2017-09-18 11:08:51.589 ceshi[2396:860809] Languagecode is en
2017-09-18 11:08:51.589 ceshi[2396:860809] Applelanguages:en-cn

iOS Language and region judgments

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.