1.0.3 • Published 2 years ago

@types/gettext.js v1.0.3

Weekly downloads
96
License
MIT
Repository
github
Last release
2 years ago

Installation

npm install --save @types/gettext.js

Summary

This package contains type definitions for gettext.js (https://github.com/guillaumepotier/gettext.js).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/gettext.js.

index.d.ts

// Type definitions for gettext.js 1.0
// Project: https://github.com/guillaumepotier/gettext.js
// Definitions by: Julien Crouzet <https://github.com/jucrouzet>
//                 Florian Schwingenschlögl <https://github.com/FlorianSchwingenschloegl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

declare namespace i18n {
    type PluralForm = (n: number) => number;

    type Optionull<T> = T | null | undefined;

    interface GettextOptions {
        domain?: string | undefined;
        locale?: string | undefined;
        plural_func?: PluralForm | undefined;
        ctxt_delimiter?: string | undefined;
    }

    interface JsonDataHeader {
        language: string;
        "plural-forms": string;
    }

    interface JsonDataMessages {
        [key: string]: string | string[] | JsonDataHeader;
    }

    interface JsonData extends JsonDataMessages {
        "": JsonDataHeader;
    }

    interface Gettext {
        setMessages(domain: string, locale: string, messages: JsonDataMessages, plural_forms?: PluralForm): Gettext;
        loadJSON(jsonData: JsonData, domain?: string): Gettext;
        setLocale(locale: string): Gettext;
        getLocale(): string;
        textdomain(domain?: string): Gettext | string;

        gettext(msgid: string, ...args: any[]): string;
        ngettext(msgid: string, msgid_plural: string, n: number, ...args: any[]): string;
        pgettext(msgctxt: string, msgid: string, ...args: any[]): string;
        dcnpgettext(domain: Optionull<string>, msgctxt: Optionull<string>, msgid: string, msgid_plural: Optionull<string>, n: Optionull<number>, ...args: any[]): string;
        __(msgid: string, ...args: any[]): string;
        _n(msgid: string, msgid_plural: string, n: number, ...args: any[]): string;
        _p(msgctxt: string, msgid: string, ...args: any[]): string;

        strfmt(fmt: string, ...args: any[]): string;
        expand_locale(locale: string): string[];
    }
}

declare function i18n(options?: i18n.GettextOptions): i18n.Gettext;

export = i18n;

Additional Details

  • Last updated: Wed, 06 Oct 2021 18:31:25 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by Julien Crouzet, and Florian Schwingenschlögl.

1.0.2

2 years ago

1.0.1

2 years ago

1.0.3

2 years ago

1.0.0

4 years ago

0.8.1

4 years ago

0.8.2

4 years ago

0.8.0

6 years ago

0.5.1

8 years ago

0.5.0

8 years ago