forked from martinandert/counterpart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a250db
commit 66849ed
Showing
3 changed files
with
75 additions
and
0 deletions.
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
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,71 @@ | ||
// @flow | ||
|
||
export type Options = { | ||
locale?: string, | ||
fallbackLocale?: string, | ||
separator?: string, | ||
fallback?: string, | ||
scope?: string | string[], | ||
interpolate?: boolean, | ||
format?: 'default' | string, | ||
type?: 'datetime' | string, | ||
// @TODO: check if other types than number are really allowed. | ||
count?: number | string | null, | ||
... | ||
}; | ||
|
||
export type NotFoundHandler = (evt: { | ||
...CustomEvent, | ||
detail: { locale: string, key: string, fallback: string, scope: string }, | ||
... | ||
}) => void; | ||
|
||
export type LocaleChangeHandler = (evt: { | ||
...CustomEvent, | ||
detail: { | ||
locale: string, | ||
previous: string, | ||
}, | ||
... | ||
}) => void; | ||
|
||
export type ErrorHandler = (evt: { | ||
...CustomEvent, | ||
detail: { | ||
error: Error, | ||
entry: string, | ||
values: Options, | ||
}, | ||
... | ||
}) => void; | ||
|
||
declare function translate(key: string | string[], options?: Options): string; | ||
|
||
declare class Counterpart { | ||
constructor(): this; | ||
|
||
translate: typeof translate; | ||
localize(date: Date, options: { ... }): string; | ||
setSeparator(value: string): string; | ||
setMissingEntryGenerator(callback: (value: string) => void): void; | ||
getLocale(): string; | ||
setLocale(value: string): string; | ||
setFallbackLocale(value: string | string[]): void; | ||
registerTranslations(locale: string, data: { ... }): void; | ||
registerInterpolations(data: { ... }): void; | ||
setKeyTransformer( | ||
callback: (value: string, options: { ... }) => string, | ||
): string; | ||
onLocaleChange(callback: LocaleChangeHandler): void; | ||
offLocaleChange(callback: LocaleChangeHandler): void; | ||
onTranslationNotFound(callback: NotFoundHandler): void; | ||
offTranslationNotFound(callback: NotFoundHandler): void; | ||
onError(callback: ErrorHandler): void; | ||
offError(callback: ErrorHandler): void; | ||
} | ||
|
||
declare module.exports: { | ||
Instance: Class<Counterpart>, | ||
Translator: Class<Counterpart>, | ||
} & Counterpart & | ||
typeof 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
"files": [ | ||
"locales", | ||
"index.js", | ||
"index.js.flow", | ||
"strftime.js", | ||
"README.md", | ||
"LICENSE" | ||
|