Typings for expo-localization

This commit is contained in:
Bartosz Dotryw 2018-11-06 12:21:18 +01:00
parent 7500ae4609
commit 4e88afacba
5 changed files with 103 additions and 1 deletions

View File

@ -0,0 +1,6 @@
import { Localization } from "expo-localization";
Localization.getLocalizationAsync().then(localization => {
localization.locale
});
Localization.locale;

73
types/expo-localization/index.d.ts vendored Normal file
View File

@ -0,0 +1,73 @@
// Type definitions for expo-localization 1.0
// Project: https://docs.expo.io/
// Definitions by: burtek <https://github.com/burtek>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface LocalizationProps {
/**
* Native device language, returned in standard format. ex: `en-US`, `es-US`
*/
locale: string;
/**
* List of all the native languages provided by the user settings. These are returned in the order the user defines in their native settings
*/
locales: string[];
/**
* Country code for your device
*/
country: string | undefined;
/**
* A list of all the supported ISO codes
*/
isoCurrencyCodes: string[] | undefined;
/**
* The current time zone in display format. ex: `America/Los_Angeles`
*/
timezone: string;
/**
* This will return `true` if the current language is Right-to-Left
*/
isRTL: boolean;
}
export class Localization {
/**
* Native device language, returned in standard format. ex: `en-US`, `es-US`
*/
static locale: string;
/**
* List of all the native languages provided by the user settings. These are returned in the order the user defines in their native settings
*/
static locales: string[];
/**
* Country code for your device
*/
static country: string | undefined;
/**
* A list of all the supported ISO codes
*/
static isoCurrencyCodes: string[] | undefined;
/**
* The current time zone in display format. ex: `America/Los_Angeles`
*/
static timezone: string;
/**
* This will return `true` if the current language is Right-to-Left
*/
static isRTL: boolean;
/**
* Android only, on iOS changing the locale settings will cause all the apps to reset
*/
static getLocalizationAsync(): Promise<LocalizationProps>;
}

View File

@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"expo-localization-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -1,7 +1,7 @@
// Type definitions for react-infinite-scroll-component 4.2
// Project: https://github.com/ankeetmaini/react-infinite-scroll-component#readme
// Definitions by: Stephanie Roy <https://github.com/sroy3>
// Bartosz Dotryw <https://github.com/burtek>
// burtek <https://github.com/burtek>
// David Kevork <https://github.com/davidkevork>
// Joshua R. <https://github.com/JoshuaScript>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped