mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +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 _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;
|
||||
|
7
platform/platform.d.ts
vendored
7
platform/platform.d.ts
vendored
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user