mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[gettext-parser] Create @types (#43325)
This commit is contained in:
parent
8029da9be3
commit
72194cc4b5
21
types/gettext-parser/gettext-parser-tests.ts
Normal file
21
types/gettext-parser/gettext-parser-tests.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { po, mo } from 'gettext-parser';
|
||||
|
||||
let parsed = po.parse("foo", "utf-8");
|
||||
let compiled = po.compile(parsed, {});
|
||||
parsed = po.parse(Buffer.from("bar"));
|
||||
compiled = po.compile(parsed, { anyOption: false });
|
||||
|
||||
parsed = mo.parse(compiled, "wrong-charset");
|
||||
compiled = mo.compile(parsed, { noOption: 3 });
|
||||
|
||||
const charset: string = parsed.charset;
|
||||
|
||||
const firstHeader: string = parsed.headers["firstHeader"];
|
||||
const firstHeaderAsString: string = firstHeader;
|
||||
|
||||
const firstTranslation = parsed.translations["firstContext"]["firstTranslation"];
|
||||
firstTranslation.msgctxt = firstHeaderAsString;
|
||||
firstTranslation.msgid = charset;
|
||||
firstTranslation.msgid_plural;
|
||||
firstTranslation.msgstr;
|
||||
firstTranslation.comments;
|
||||
42
types/gettext-parser/index.d.ts
vendored
Normal file
42
types/gettext-parser/index.d.ts
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
// Type definitions for gettext-parser 4.0
|
||||
// Project: https://github.com/smhg/gettext-parser
|
||||
// Definitions by: Lorent Lempereur <https://github.com/looorent>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface GetTextComment {
|
||||
translator: string;
|
||||
reference: string;
|
||||
extracted: string;
|
||||
flag: string;
|
||||
previous: string;
|
||||
}
|
||||
|
||||
export interface GetTextTranslation {
|
||||
msgctxt?: string;
|
||||
msgid: string;
|
||||
msgid_plural?: any;
|
||||
msgstr: string[];
|
||||
comments?: GetTextComment;
|
||||
}
|
||||
|
||||
export interface GetTextTranslations {
|
||||
charset: string;
|
||||
headers: { [headerName: string]: string };
|
||||
translations: { [msgctxt: string]: { [msgId: string]: GetTextTranslation } };
|
||||
}
|
||||
|
||||
export interface PoParser {
|
||||
parse: (buffer: Buffer | string, defaultCharset?: string) => GetTextTranslations;
|
||||
compile: (table: GetTextTranslations, options?: any) => Buffer;
|
||||
createParseStream: (buffer: any, defaultCharset?: string) => any;
|
||||
}
|
||||
|
||||
export interface MoParser {
|
||||
parse: (buffer: Buffer | string, defaultCharset?: string) => GetTextTranslations;
|
||||
compile: (table: GetTextTranslations, options?: any) => Buffer;
|
||||
}
|
||||
|
||||
export const po: MoParser;
|
||||
export const mo: MoParser;
|
||||
23
types/gettext-parser/tsconfig.json
Normal file
23
types/gettext-parser/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"gettext-parser-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/gettext-parser/tslint.json
Normal file
1
types/gettext-parser/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user