forked from musterknabe/translate.js
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from Kurounin/typings
Added typings
- Loading branch information
Showing
3 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Type definitions for translate.js 1.2.1 | ||
// Project: https://github.com/StephanHoyer/translate.js#readme | ||
// Definitions by: Kurounin <https://github.com/Kurounin> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.8 | ||
|
||
interface Params { | ||
[key: string]: string; | ||
} | ||
|
||
export interface Messages { | ||
[key: string]: string | Messages; | ||
[key: number]: string | Messages; | ||
} | ||
|
||
type translateFunc1<T> = (key: string) => T; | ||
type translateFunc2<T> = (key: string, subKey: number | string) => T; | ||
type translateFunc3<T> = (key: string, params: Params) => T; | ||
type translateFunc4<T> = (key: string, subKey: number | string, params: Params) => T; | ||
type translateFunc5<T> = (key: string, params: Params, subKey: number | string) => T; | ||
|
||
export interface Options { | ||
debug?: boolean; | ||
array?: boolean; | ||
resolveAliases?: boolean; | ||
pluralize?: (n: number, translationKey: string) => number | string; | ||
useKeyForMissingTranslation?: boolean; | ||
} | ||
|
||
export interface ArrayOptions extends Options { | ||
array: true; | ||
} | ||
|
||
export type Translate<T extends ArrayOptions | Options> = { | ||
keys: Messages; | ||
arr: translateFunc1<any[]> & translateFunc2<any[]> & translateFunc3<any[]> & translateFunc4<any[]> & translateFunc5<any[]>; | ||
opts: T; | ||
} | ||
& translateFunc1<T extends ArrayOptions ? any[] : string> | ||
& translateFunc2<T extends ArrayOptions ? any[] : string> | ||
& translateFunc3<T extends ArrayOptions ? any[] : string> | ||
& translateFunc4<T extends ArrayOptions ? any[] : string> | ||
& translateFunc5<T extends ArrayOptions ? any[] : string>; | ||
|
||
type translateJsFunc1 = (messages: Messages) => Translate<Options>; | ||
type translateJsFunc2 = (messages: Messages, options: ArrayOptions) => Translate<ArrayOptions>; | ||
type translateJsFunc3 = (messages: Messages, options: Options) => Translate<Options>; | ||
|
||
type translateJs = { | ||
resolveAliases: (messages: Messages) => Messages; | ||
} & translateJsFunc1 & translateJsFunc2 & translateJsFunc3; | ||
|
||
declare const translate: translateJs; | ||
|
||
export default translate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Type definitions for translate.js/plurals 1.2.1 | ||
// Project: https://github.com/StephanHoyer/translate.js#readme | ||
// Definitions by: Kurounin <https://github.com/Kurounin> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.8 | ||
|
||
type plural = (n: number, translationKey: string) => string; | ||
|
||
export const plural_CS: plural; | ||
export const plural_DA: plural; | ||
export const plural_DE: plural; | ||
export const plural_EN: plural; | ||
export const plural_ES: plural; | ||
export const plural_FR: plural; | ||
export const plural_IS: plural; | ||
export const plural_IT: plural; | ||
export const plural_JA: plural; | ||
export const plural_PT: plural; | ||
export const plural_SE: plural; |