mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Merge pull request #31856 from sameercaresu/master
Adding types for node-gettext
This commit is contained in:
27
node-gettext/index.d.ts
vendored
Normal file
27
node-gettext/index.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// Type definitions for node-gettext 2.0
|
||||
// Project: http://github.com/alexanderwallin/node-gettext
|
||||
// Definitions by: Sameer K.C. <https://github.com/sameercaresu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = GetText;
|
||||
declare class GetText {
|
||||
constructor(options?: { debug: boolean; });
|
||||
addTranslations(locale: string, domain: string, translations: object): void;
|
||||
dgettext(domain: string, msgid: string): string;
|
||||
dngettext(domain: string, msgid: string, msgidPlural: string, count: number): string;
|
||||
dnpgettext(domain: string, msgctxt: string, msgid: string, msgidPlural: string, count: number): string;
|
||||
dpgettext(domain: string, msgctxt: string, msgid: string): string;
|
||||
emit(eventName: string, eventData: any): void;
|
||||
getComment(domain: string, msgctxt: string, msgid: string): object | boolean;
|
||||
gettext(msgid: string): string;
|
||||
ngettext(msgid: string, msgidPlural: string, count: number): string;
|
||||
npgettext(msgctxt: string, msgid: string, msgidPlural: string, count: number): string;
|
||||
off(eventName: string, callback: (params: any) => void): string;
|
||||
on(eventName: string, callback: (params: any) => void): void;
|
||||
pgettext(msgctxt: string, msgid: string): string;
|
||||
setLocale(locale: string): void;
|
||||
setTextDomain(domain: string): void;
|
||||
static getLanguageCode(locale: string): string;
|
||||
textdomain(domain: string): void;
|
||||
warn(message: string): void;
|
||||
}
|
||||
34
node-gettext/node-gettext-tests.ts
Normal file
34
node-gettext/node-gettext-tests.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
// with tsc v 2.7 & esModuleInterop & allowSyntheticDefaultImports enabled in tsconfig.json
|
||||
import Gettext from 'node-gettext';
|
||||
// or without
|
||||
// import Gettext = require('node-getttext');
|
||||
|
||||
const translations = {};
|
||||
const gt = new Gettext({ debug: true });
|
||||
const msgid = 'Get translation';
|
||||
const msgidPlural = 'Get translations';
|
||||
const domain = 'domain';
|
||||
const msgctxt = 'context';
|
||||
const count = 2;
|
||||
|
||||
gt.addTranslations('en-US', 'messages', translations);
|
||||
gt.setTextDomain(domain);
|
||||
gt.textdomain(domain);
|
||||
gt.setLocale('en-US');
|
||||
gt.gettext(msgid);
|
||||
gt.dgettext('', msgid);
|
||||
gt.dngettext(domain, msgid, msgidPlural, count);
|
||||
gt.dnpgettext(domain, msgctxt, msgid, msgidPlural, count);
|
||||
gt.dpgettext(domain, msgctxt, msgid);
|
||||
gt.getComment(domain, msgctxt, msgid);
|
||||
gt.ngettext(msgid, msgidPlural, count);
|
||||
gt.npgettext(msgctxt, msgid, msgidPlural, count);
|
||||
gt.pgettext(msgctxt, msgid);
|
||||
Gettext.getLanguageCode('en-US');
|
||||
gt.warn('warning');
|
||||
const errorListener = (error: string) => {
|
||||
// do something;
|
||||
};
|
||||
gt.on('error', errorListener);
|
||||
gt.emit('error', 'Error occurred');
|
||||
gt.off('error', errorListener);
|
||||
24
node-gettext/tsconfig.json
Normal file
24
node-gettext/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"node-gettext-tests.ts"
|
||||
]
|
||||
}
|
||||
1
node-gettext/tslint.json
Normal file
1
node-gettext/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user