mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00
Merge pull request #1117 from NativeScript/platformModule
region property added;change in how to get the language in android
This commit is contained in:
@ -19,6 +19,7 @@ export class device implements definition.device {
|
|||||||
private static _deviceType: string;
|
private static _deviceType: string;
|
||||||
private static _uuid: string;
|
private static _uuid: string;
|
||||||
private static _language: string;
|
private static _language: string;
|
||||||
|
private static _region: string;
|
||||||
|
|
||||||
static get os(): string {
|
static get os(): string {
|
||||||
return platformNames.android;
|
return platformNames.android;
|
||||||
@ -85,11 +86,19 @@ export class device implements definition.device {
|
|||||||
|
|
||||||
static get language(): string {
|
static get language(): string {
|
||||||
if (!device._language) {
|
if (!device._language) {
|
||||||
device._language = java.util.Locale.getDefault().toString();
|
device._language = java.util.Locale.getDefault().getLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return device._language;
|
return device._language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get region(): string {
|
||||||
|
if(!device._region) {
|
||||||
|
device._region = java.util.Locale.getDefault().getCountry();
|
||||||
|
}
|
||||||
|
|
||||||
|
return device._region;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mainScreen: MainScreen;
|
var mainScreen: MainScreen;
|
||||||
|
7
platform/platform.d.ts
vendored
7
platform/platform.d.ts
vendored
@ -61,9 +61,14 @@ declare module "platform" {
|
|||||||
static uuid: string;
|
static uuid: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the preferred language. For example "en" or "en_US"
|
* Gets the preferred language. For example "en"
|
||||||
*/
|
*/
|
||||||
static language: string;
|
static language: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the preferred region. For example "US"
|
||||||
|
*/
|
||||||
|
static region: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,6 +15,7 @@ export class device implements definition.device {
|
|||||||
private static _sdkVersion: string;
|
private static _sdkVersion: string;
|
||||||
private static _deviceType: string;
|
private static _deviceType: string;
|
||||||
private static _language: string;
|
private static _language: string;
|
||||||
|
private static _region: string;
|
||||||
|
|
||||||
static get manufacturer(): string {
|
static get manufacturer(): string {
|
||||||
return "Apple";
|
return "Apple";
|
||||||
@ -84,6 +85,14 @@ export class device implements definition.device {
|
|||||||
|
|
||||||
return device._language;
|
return device._language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get region(): string {
|
||||||
|
if(!device._region) {
|
||||||
|
device._region = NSLocale.currentLocale().objectForKey(NSLocaleCountryCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return device._region;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mainScreen: MainScreen;
|
var mainScreen: MainScreen;
|
||||||
|
Reference in New Issue
Block a user