-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Partially copied from wikimedia/banana-i18n#25
- Loading branch information
1 parent
b61d9a7
commit 7e94fed
Showing
2 changed files
with
58 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,57 @@ | ||
export class Banana { | ||
constructor(locale: string, options?: BananaOptions); | ||
locale: string; | ||
parser: BananaParser; | ||
messageStore: BananaMessageStore; | ||
finalFallback: string; | ||
|
||
load(messsageSource: MessageSource, locale?: string): void; | ||
i18n(key: string, ...params: ParameterType[]): string; | ||
setLocale(locale: string): void; | ||
getFallbackLocales(): string[]; | ||
getMessage(messageKey: string): string; | ||
} | ||
|
||
export interface BananaOptions { | ||
messages?: Messages; | ||
finalFallback?: string; | ||
} | ||
|
||
export interface Messages { | ||
[messageKey: string]: string; | ||
} | ||
|
||
export interface MessageSource { | ||
[localizer: string]: Messages; | ||
} | ||
|
||
export type ParameterType = string | object | number | undefined; | ||
|
||
export class BananaParser { | ||
constructor (locale: string, options?: { wikilinks: boolean }); | ||
locale: string; | ||
wikilinks: boolean; | ||
emitter: BananaEmitter; | ||
} | ||
|
||
export class BananaEmitter { | ||
constructor(locale: string); | ||
emit(node: any, replacements: any): any; | ||
concat(nodes: any): string; | ||
replace (nodes: any, replacements: any): string; | ||
plural(nodes: any): string; | ||
gender(nodes: any): string; | ||
grammar(nodes: any): string; | ||
wikilink(nodes: any): string; | ||
extlink(nodes: any): string; | ||
bidi(nodes: any): string; | ||
formatnum(nodes: any): string; | ||
} | ||
|
||
export class BananaMessageStore { | ||
constructor(); | ||
load(messageSource: Messages, locale: string): void; | ||
getMessage(key: string, locale: string): string; | ||
hasLocale(locale: string): boolean; | ||
} | ||
|