mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Add counterpart
This commit is contained in:
29
types/counterpart/counterpart-tests.ts
Normal file
29
types/counterpart/counterpart-tests.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import * as counterpart from 'counterpart';
|
||||
|
||||
counterpart('translation.to.be.used');
|
||||
counterpart(['translation', 'to', 'be', 'used']);
|
||||
|
||||
counterpart.setSeparator('*');
|
||||
|
||||
counterpart.onTranslationNotFound((locale: string, key: string, fallback: string, scope: string) => {});
|
||||
counterpart.offTranslationNotFound((locale: string, key: string, fallback: string, scope: string) => {});
|
||||
|
||||
counterpart.setMissingEntryGenerator((value: string) => {});
|
||||
|
||||
counterpart.setLocale('es');
|
||||
counterpart.getLocale();
|
||||
|
||||
counterpart.onLocaleChange((newLocale: string, oldLocale: string) => {});
|
||||
counterpart.offLocaleChange((newLocale: string, oldLocale: string) => {});
|
||||
|
||||
counterpart.setFallbackLocale('es');
|
||||
|
||||
counterpart.registerTranslations('es', { hello: 'Hola' });
|
||||
|
||||
counterpart.registerInterpolations({ library: 'Counterpart' });
|
||||
|
||||
counterpart.setKeyTransformer((value: string, options: object) => {
|
||||
return value.toUpperCase();
|
||||
});
|
||||
|
||||
counterpart.localize(new Date(), { format: 'short' });
|
||||
32
types/counterpart/index.d.ts
vendored
Normal file
32
types/counterpart/index.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
// Type definitions for counterpart 0.18
|
||||
// Project: https://github.com/martinandert/counterpart
|
||||
// Definitions by: santiagodoldan <https://github.com/santiagodoldan>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
type NotFoundHandler = (locale: string, key: string, fallback: string, scope: string) => void;
|
||||
type LocaleChangeHandler = (newLocale: string, oldLocale: string) => void;
|
||||
|
||||
interface Counterpart {
|
||||
(key: string|string[], options?: object): string;
|
||||
|
||||
setSeparator(value: string): string;
|
||||
onTranslationNotFound(callback: NotFoundHandler): void;
|
||||
offTranslationNotFound(callback: NotFoundHandler): void;
|
||||
setMissingEntryGenerator(callback: (value: string) => void): void;
|
||||
getLocale(): string;
|
||||
setLocale(value: string): string;
|
||||
onLocaleChange(callback: LocaleChangeHandler): void;
|
||||
offLocaleChange(callback: LocaleChangeHandler): void;
|
||||
setFallbackLocale(value: string|string[]): void;
|
||||
registerTranslations(locale: string, data: object): void;
|
||||
registerInterpolations(data: object): void;
|
||||
setKeyTransformer(callback: (value: string, options: object) => string): string;
|
||||
localize(date: Date, options: object): string;
|
||||
Instance: Counterpart;
|
||||
Translator: Counterpart;
|
||||
}
|
||||
|
||||
declare var counterpart: Counterpart;
|
||||
|
||||
export = counterpart;
|
||||
22
types/counterpart/tsconfig.json
Normal file
22
types/counterpart/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"counterpart-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/counterpart/tslint.json
Normal file
1
types/counterpart/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user