mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Add type definitions for the i18n-abide package. (#29855)
* Add type definitions for the i18n-abide library. * Fix test and tsconfig.
This commit is contained in:
committed by
Sheetal Nandi
parent
310fdc8633
commit
e409eb2907
@@ -0,0 +1,38 @@
|
||||
import * as i18n from 'i18n-abide';
|
||||
|
||||
const emptyAbideOptions: i18n.AbideOptions = {};
|
||||
const fullAbideOptions: i18n.AbideOptions = {
|
||||
gettext_alias: 'gettext',
|
||||
supported_languages: ['en-US'],
|
||||
default_lang: 'en-US',
|
||||
debug_lang: 'it-CH',
|
||||
disable_locale_check: false,
|
||||
translation_directory: 'l18n/',
|
||||
logger: { warn(msg: string) {}, error(msg: string) {} },
|
||||
};
|
||||
|
||||
i18n.abide(); // $ExpectType RequestHandler
|
||||
i18n.abide(emptyAbideOptions); // $ExpectType RequestHandler
|
||||
i18n.abide(fullAbideOptions); // $ExpectType RequestHandler
|
||||
|
||||
i18n.parseAcceptLanguage(""); // $ExpectType { lang: string; quality: number; }[]
|
||||
|
||||
i18n.bestLanguage([{lang: 'en-US', quality: 1.0}], ['en-US'], 'en-US'); // $ExpectType string
|
||||
|
||||
i18n.localeFrom(); // $ExpectType string
|
||||
i18n.localeFrom(""); // $ExpectType string
|
||||
|
||||
i18n.languageFrom(); // $ExpectType string
|
||||
i18n.languageFrom(""); // $ExpectType string
|
||||
|
||||
i18n.normalizeLanguage(); // $ExpectType string
|
||||
i18n.normalizeLanguage(""); // $ExpectType string
|
||||
|
||||
i18n.normalizeLocale(); // $ExpectType string
|
||||
i18n.normalizeLocale(""); // $ExpectType string
|
||||
|
||||
i18n.format(""); // $ExpectType string
|
||||
i18n.format("", {}); // $ExpectType string
|
||||
i18n.format("", {}, false); // $ExpectType string
|
||||
|
||||
i18n.getLocales(); // $ExpectType string[]
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// Type definitions for i18n-abide 0.0
|
||||
// Project: https://github.com/mozilla/i18n-abide
|
||||
// Definitions by: Steven Bell <https://github.com/smbell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import { RequestHandler } from 'express';
|
||||
|
||||
export function abide(options?: AbideOptions): RequestHandler;
|
||||
export function parseAcceptLanguage(header?: string): Array<{ lang: string, quality: number }>;
|
||||
export function bestLanguage(languages: Array<{ lang: string, quality: number}>, supported_languages: string[], defaultLanguage: string): string;
|
||||
export function localeFrom(language?: string): string;
|
||||
export function languageFrom(locale?: string): string;
|
||||
export function normalizeLanguage(language?: string): string;
|
||||
export function normalizeLocale(locale?: string): string;
|
||||
export function format(fmt: string, obj?: any, named?: boolean): string;
|
||||
export function getLocales(): string[];
|
||||
|
||||
export interface AbideOptions {
|
||||
gettext_alias?: string;
|
||||
supported_languages?: string[];
|
||||
default_lang?: string;
|
||||
debug_lang?: string;
|
||||
disable_locale_check?: boolean;
|
||||
translation_directory?: string;
|
||||
logger?: { warn(msg: string): void, error(msg: string): void };
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"i18n-abide-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user