@@ -13,23 +13,6 @@ export type TranslationOptions = {
1313 prefix ?: string | null ;
1414} ;
1515
16- /*
17- export interface TranslationConstructor<N extends number> {
18- new (name: string, options: TranslationWithArgsOptions<N>): TranslationWithArgs<N>;
19- new (name: string, options?: TranslationOptions): TranslationBase;
20- new (name: string, options?: TranslationOptions | TranslationWithArgsOptions<N>): TranslationBase | TranslationWithArgs<N>;
21-
22- Chat(key: string): TranslationBase;
23- Chat(key: string, hasArgs: N): TranslationWithArgs<N>;
24- Chat(key: string, ...args: Tuple<string, N>): TranslationBase;
25- Chat(
26- key: string,
27- hasArgs?: string | number,
28- ...rest: string[]
29- ): TranslationBase | TranslationWithArgs<N>;
30- }
31- // */
32-
3316export interface TranslationBase {
3417 readonly key : string ;
3518 toString ( ) : string ;
@@ -44,13 +27,15 @@ export interface TranslationWithArgs<N extends number> extends TranslationBase {
4427}
4528
4629export default class Translation extends Constant implements TranslationBase {
47- static DISMISS = new Translation ( 'general.dismiss' , { fallback : 'Dismiss' } ) ;
48- static ERROR = new Translation ( 'general.error' , { fallback : 'Error' } ) ;
49- static OPEN = new Translation ( 'general.open' , { fallback : 'Open' } ) ;
50- static UNDO = new Translation ( 'general.undo' , { fallback : 'Undo' } ) ;
51- static UNKNOWN = new Translation ( 'general.unknown' , { fallback : 'Unknown' } ) ;
52- static UPDATE = new Translation ( 'general.update' , { fallback : 'Update' } ) ;
53-
30+ static DISMISS = this . General ( 'dismiss' , 'Dismiss' ) ;
31+ static ERROR = this . General ( 'error' , 'Error' ) ;
32+ static OPEN = this . General ( 'open' , 'Open' ) ;
33+ static PURCHASE = this . General ( 'purchase.item' ) ;
34+ static UNDO = this . General ( 'undo' , 'Undo' ) ;
35+ static UNKNOWN = this . General ( 'unknown' , 'Unknown' ) ;
36+ static UPDATE = this . General ( 'update' , 'Update' ) ;
37+
38+ static CATEGORY_CARD_SKINS = this . Setting ( 'category.card.skins' ) ;
5439 static CATEGORY_CHAT_COMMAND = this . Setting ( 'category.chat.commands' ) ;
5540 static CATEGORY_CHAT_IGNORED = this . Setting ( 'category.chat.ignored' ) ;
5641 static CATEGORY_CHAT_IMPORT = this . Setting ( 'category.chat.import' ) ;
@@ -59,16 +44,20 @@ export default class Translation extends Constant implements TranslationBase {
5944 static CATEGORY_HOME = this . Setting ( 'category.home' ) ;
6045 static CATEGORY_HOTKEYS = this . Setting ( 'category.hotkeys' ) ;
6146 static CATEGORY_LIBRARY_CRAFTING = this . Setting ( 'category.library.crafting' ) ;
47+ static CATEGORY_MINIGAMES = this . Setting ( 'category.minigames' ) ;
48+ static CATEGORY_OUTLINE = this . Setting ( 'category.outline' ) ;
6249 static CATEGORY_PLUGINS = this . Setting ( 'category.plugins' ) ;
6350 static CATEGORY_STREAMER = this . Setting ( 'category.streamer' ) ;
6451 static CATEGORY_UPDATES = this . Setting ( 'category.updates' ) ;
6552
6653 static DISABLE_COMMAND_SETTING = this . Setting ( 'command' , 1 ) ;
6754
6855 static IGNORED = this . Toast ( 'ignore' , 1 ) ;
69- static INFO = new Translation ( 'toast.info' , { fallback : 'Did you know?' } ) ;
56+ static INFO = this . Toast ( 'toast.info' , 'Did you know?' ) ;
7057
71- static CLOSE = this . Vanilla ( 'dialog-close' ) ;
58+ static CANCEL = this . Vanilla ( 'dialog-cancel' , 'Cancel' ) ;
59+ static CLOSE = this . Vanilla ( 'dialog-close' , 'Close' ) ;
60+ static CONTINUE = this . Vanilla ( 'dialog-continue' , 'Continue' ) ;
7261
7362 private args : string [ ] ;
7463 private fallback ?: string ;
@@ -110,42 +99,42 @@ export default class Translation extends Constant implements TranslationBase {
11099 }
111100
112101 static General ( key : string ) : Translation ;
102+ static General < N extends number > ( key : string , fallback : string ) : Translation ;
113103 static General < N extends number > ( key : string , hasArgs : N ) : TranslationWithArgs < N > ;
114- static General < N extends number > ( key : string , ...args : Tuple < string , N > ) : TranslationWithArgs < N > ;
115- static General < N extends number > ( key : string , hasArgs ?: string | N , ...rest : string [ ] ) : TranslationBase | TranslationWithArgs < N > {
116- const args = typeof hasArgs === 'string' ? [ hasArgs , ...rest ] : rest ;
117- return new Translation ( `general.${ key } ` , { args } ) ;
104+ static General < N extends number > ( key : string , text ?: string | N ) : TranslationBase | TranslationWithArgs < N > {
105+ const fallback = typeof text === 'string' ? text : undefined ;
106+ return new Translation ( `general.${ key } ` , { fallback } ) ;
118107 }
119108
120109 static Menu ( key : string ) : Translation ;
110+ static Menu < N extends number > ( key : string , fallback : string ) : Translation ;
121111 static Menu < N extends number > ( key : string , hasArgs : N ) : TranslationWithArgs < N > ;
122- static Menu < N extends number > ( key : string , ...args : Tuple < string , N > ) : TranslationWithArgs < N > ;
123- static Menu < N extends number > ( key : string , hasArgs ?: string | N , ...rest : string [ ] ) : TranslationBase | TranslationWithArgs < N > {
124- const args = typeof hasArgs === 'string' ? [ hasArgs , ...rest ] : rest ;
125- return new Translation ( `menu.${ key } ` , { args } ) ;
112+ static Menu < N extends number > ( key : string , text ?: string | N ) : TranslationBase | TranslationWithArgs < N > {
113+ const fallback = typeof text === 'string' ? text : undefined ;
114+ return new Translation ( `menu.${ key } ` , { fallback } ) ;
126115 }
127116
128117 static Setting ( key : string ) : Translation ;
118+ static Setting < N extends number > ( key : string , fallback : string ) : Translation ;
129119 static Setting < N extends number > ( key : string , hasArgs : N ) : TranslationWithArgs < N > ;
130- static Setting < N extends number > ( key : string , ...args : Tuple < string , N > ) : TranslationWithArgs < N > ;
131- static Setting < N extends number > ( key : string , hasArgs ?: string | N , ...rest : string [ ] ) : TranslationBase | TranslationWithArgs < N > {
132- const args = typeof hasArgs === 'string' ? [ hasArgs , ...rest ] : rest ;
133- return new Translation ( `settings.${ key } ` , { args } ) ;
120+ static Setting < N extends number > ( key : string , text ?: string | N ) : TranslationBase | TranslationWithArgs < N > {
121+ const fallback = typeof text === 'string' ? text : undefined ;
122+ return new Translation ( `settings.${ key } ` , { fallback } ) ;
134123 }
135124
136125 static Toast ( key : string ) : Translation ;
126+ static Toast < N extends number > ( key : string , fallback : string ) : Translation ;
137127 static Toast < N extends number > ( key : string , hasArgs : N ) : TranslationWithArgs < N > ;
138- static Toast < N extends number > ( key : string , ...args : Tuple < string , N > ) : TranslationWithArgs < N > ;
139- static Toast < N extends number > ( key : string , hasArgs ?: string | N , ...rest : string [ ] ) : TranslationBase | TranslationWithArgs < N > {
140- const args = typeof hasArgs === 'string' ? [ hasArgs , ...rest ] : rest ;
141- return new Translation ( `toast.${ key } ` , { args } ) ;
128+ static Toast < N extends number > ( key : string , text ?: string | N ) : TranslationBase | TranslationWithArgs < N > {
129+ const fallback = typeof text === 'string' ? text : undefined ;
130+ return new Translation ( `toast.${ key } ` , { fallback } ) ;
142131 }
143132
144133 static Vanilla ( key : string ) : Translation ;
134+ static Vanilla < N extends number > ( key : string , fallback : string ) : Translation
145135 static Vanilla < N extends number > ( key : string , hasArgs : N ) : TranslationWithArgs < N > ;
146- static Vanilla < N extends number > ( key : string , ...args : Tuple < string , N > ) : TranslationWithArgs < N > ;
147- static Vanilla < N extends number > ( key : string , hasArgs ?: string | N , ...rest : string [ ] ) : TranslationBase | TranslationWithArgs < N > {
148- const args = typeof hasArgs === 'string' ? [ hasArgs , ...rest ] : rest ;
149- return new Translation ( key . toLowerCase ( ) , { args, prefix : null } ) ;
136+ static Vanilla < N extends number > ( key : string , text ?: string | number ) : TranslationBase | TranslationWithArgs < N > {
137+ const fallback = typeof text === 'string' ? text : undefined ;
138+ return new Translation ( key . toLowerCase ( ) , { fallback, prefix : null } ) ;
150139 }
151140}
0 commit comments