DefinitelyTyped/types/node-polyglot/index.d.ts
Michael Mok b5deac6480 [node-polyglot] Add types for new options and static methods from latest release (#37991)
* [node-polyglot] Update types to match v2.3.1

* [node-polyglot] Update tests to match types

* [node-polyglot] Run prettier on test file

* [node-polyglot] Add myself to the contributors list

Co-Authored-By: Liam Ross <liamross.code@gmail.com>
2019-09-05 11:25:56 -07:00

52 lines
1.4 KiB
TypeScript

// Type definitions for node-polyglot v0.4.4
// Project: https://github.com/airbnb/polyglot.js
// Definitions by: Tim Jackson-Kiely <https://github.com/timjk>
// Liam Ross <https://github.com/liamross>
// Michael Mok <https://github.com/pmmmwh>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace Polyglot {
interface InterpolationOptions {
smart_count?: number | { length: number };
_?: string;
[interpolationKey: string]: any;
}
interface InterpolationTokenOptions {
prefix?: string;
suffix?: string;
}
interface PolyglotOptions {
phrases?: any;
locale?: string;
allowMissing?: boolean;
onMissingKey?: (key: string, options?: Polyglot.InterpolationOptions, locale?: string) => string;
warn?: (message: string) => void;
interpolation?: InterpolationTokenOptions;
}
function transformPhrase(phrase: string, options?: number | Polyglot.InterpolationOptions, locale?: string): string;
}
declare class Polyglot {
constructor(options?: Polyglot.PolyglotOptions);
extend(phrases: any, prefix?: string): void;
t(phrase: string, options?: number | Polyglot.InterpolationOptions): string;
clear(): void;
replace(phrases: any): void;
locale(locale?: string): string;
has(phrase: string): boolean;
unset(phrases: any, prefix?: string): void;
}
export = Polyglot;