2.5.0 • Published 6 months ago

@types/node-polyglot v2.5.0

Weekly downloads
11,441
License
MIT
Repository
github
Last release
6 months ago

Installation

npm install --save @types/node-polyglot

Summary

This package contains type definitions for node-polyglot (https://github.com/airbnb/polyglot.js).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-polyglot.

index.d.ts

// Type definitions for node-polyglot v2.4.0
// 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 } | undefined;
        _?: string | undefined;

        [interpolationKey: string]: any;
    }

    interface InterpolationTokenOptions {
        prefix?: string | undefined;
        suffix?: string | undefined;
    }

    interface PluralRules {
        pluralTypes: {[lang: string]: (n: number) => number};
        pluralTypeToLanguages: {[lang: string]: string[]};
    }

    interface PolyglotOptions {
        phrases?: any;
        locale?: string | undefined;
        allowMissing?: boolean | undefined;
        onMissingKey?: ((key: string, options: Polyglot.InterpolationOptions, locale: string) => string) | undefined;
        warn?: ((message: string) => void) | undefined;
        interpolation?: InterpolationTokenOptions | undefined;
        pluralRules?: PluralRules | undefined;
    }

    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;

Additional Details

  • Last updated: Thu, 08 Jul 2021 18:51:23 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by Tim Jackson-Kiely, Liam Ross, and Michael Mok.