Merge pull request #1117 from NativeScript/platformModule

region property added;change in how to get the language in android
This commit is contained in:
Neli Chakarova
2015-11-19 11:01:13 +02:00
3 changed files with 25 additions and 2 deletions

View File

@ -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;

View File

@ -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;
}
/**

View File

@ -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;