-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 0.0.3 and working typescript
- Loading branch information
1 parent
7e0e4f3
commit 9171765
Showing
6 changed files
with
148 additions
and
242 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 |
---|---|---|
@@ -1,24 +1,29 @@ | ||
declare type val<T> = (...params: any[]) => T; | ||
declare type val1<T> = T; | ||
declare type Translations<T> = { | ||
[group: string]: { | ||
[key: string]: val<T> | val1<T>; | ||
declare type CopyFunction<TFn, TR> = TFn extends (...a: infer A) => any ? (...a: A) => TR : string; | ||
declare type ValueOf<T> = T[keyof T]; | ||
declare type Translations<TGroup> = { | ||
[group in keyof TGroup]: { | ||
[key in keyof ValueOf<TGroup>]: CopyFunction<ValueOf<TGroup>[key], string>; | ||
}; | ||
}; | ||
declare type EasierTranslations<T> = { | ||
declare type Options<TValue> = { | ||
language: keyof TValue; | ||
fallback: keyof TValue; | ||
}; | ||
declare type TranslationsObject<TGroup, TValue> = { | ||
translations: Translations<TGroup>; | ||
use: () => Translations<TGroup>; | ||
setOptions: (options: Options<TValue>) => any; | ||
getOptions: () => Options<TValue>; | ||
}; | ||
declare type val<T> = (...params: any[]) => T; | ||
declare type val1<T> = T; | ||
declare type TranslationInput<TValue> = { | ||
[group: string]: { | ||
[key: string]: val<string> | val1<string>; | ||
[key: string]: val<TValue> | val1<TValue>; | ||
}; | ||
}; | ||
declare type Options<T> = { | ||
language: keyof T; | ||
fallback: keyof T; | ||
}; | ||
declare type TranslationsObject<T> = { | ||
translations: EasierTranslations<T>; | ||
use: () => EasierTranslations<T>; | ||
setOptions: (options: Options<T>) => any; | ||
getOptions: () => Options<T>; | ||
declare type TranslationLanguagesInput = { | ||
[language: string]: string; | ||
}; | ||
export declare function createTranslations<T>(t: Translations<T>, po: Options<T>): TranslationsObject<T>; | ||
export declare function createTranslations<TValue extends TranslationLanguagesInput>(): <TGroup extends TranslationInput<TValue>>(t: TGroup, po: Options<TValue>) => TranslationsObject<TGroup, TValue>; | ||
export {}; |
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
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
Oops, something went wrong.