@types/gettext.js
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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.

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?: string,
        ): Gettext;
        loadJSON(jsonData: JsonData | string, 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: Tue, 06 May 2025 14:02:13 GMT
  • Dependencies: none

Credits

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

Readme

Keywords

none

Package Sidebar

Install

npm i @types/gettext.js

Weekly Downloads

882

Version

2.0.0

License

MIT

Unpacked Size

6.59 kB

Total Files

5

Last publish

Collaborators

  • types