From 1e0c82a8d49f4eb9d0ce31246be744307900a432 Mon Sep 17 00:00:00 2001 From: Neli Chakarova Date: Wed, 18 Nov 2015 15:41:20 +0200 Subject: [PATCH 1/2] region property added;chnage in how to get the language in android --- platform/platform.android.ts | 11 ++++++++++- platform/platform.ios.ts | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/platform/platform.android.ts b/platform/platform.android.ts index 69f008092..148d5bcab 100644 --- a/platform/platform.android.ts +++ b/platform/platform.android.ts @@ -19,6 +19,7 @@ export class device implements definition.device { private static _deviceType: string; private static _uuid: string; private static _language: string; + private static _region: string; static get os(): string { return platformNames.android; @@ -85,11 +86,19 @@ export class device implements definition.device { static get language(): string { if (!device._language) { - device._language = java.util.Locale.getDefault().toString(); + device._language = java.util.Locale.getDefault().getLanguage(); } return device._language; } + + static get region(): string { + if(!device._region) { + device._region = java.util.Locale.getDefault().getCountry(); + } + + return device._region; + } } var mainScreen: MainScreen; diff --git a/platform/platform.ios.ts b/platform/platform.ios.ts index 1f76a58c5..d5e0c3a32 100644 --- a/platform/platform.ios.ts +++ b/platform/platform.ios.ts @@ -15,6 +15,7 @@ export class device implements definition.device { private static _sdkVersion: string; private static _deviceType: string; private static _language: string; + private static _region: string; static get manufacturer(): string { return "Apple"; @@ -84,6 +85,14 @@ export class device implements definition.device { return device._language; } + + static get region(): string { + if(!device._region) { + device._region = NSLocale.currentLocale().objectForKey(NSLocaleCountryCode); + } + + return device._region; + } } var mainScreen: MainScreen; From 68ca2bbd2e3f52b34f8ea81b35d139872ec15e43 Mon Sep 17 00:00:00 2001 From: Neli Chakarova Date: Wed, 18 Nov 2015 15:52:27 +0200 Subject: [PATCH 2/2] region property added in platform.d.ts --- platform/platform.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/platform.d.ts b/platform/platform.d.ts index ddae89346..21f639f84 100644 --- a/platform/platform.d.ts +++ b/platform/platform.d.ts @@ -61,9 +61,14 @@ declare module "platform" { static uuid: string; /** - * Gets the preferred language. For example "en" or "en_US" + * Gets the preferred language. For example "en" */ static language: string; + + /** + * Gets the preferred region. For example "US" + */ + static region: string; } /**