mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[@wordpress/i18n] add new definitions (#35908)
* [@wordpress/i18n] add new definitions * fix lint warnings
This commit is contained in:
parent
063fc9d608
commit
18b549ebcd
87
types/wordpress__i18n/index.d.ts
vendored
Normal file
87
types/wordpress__i18n/index.d.ts
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
// Type definitions for @wordpress/i18n 3.4
|
||||
// Project: https://github.com/WordPress/gutenberg/tree/master/packages/i18n/README.md
|
||||
// Definitions by: Derek Sifford <https://github.com/dsifford>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Merges locale data into the Tannin instance by domain. Accepts data in a
|
||||
* Jed-formatted JSON object shape.
|
||||
*
|
||||
* @see http://messageformat.github.io/Jed/
|
||||
*
|
||||
* @param data Locale data configuration.
|
||||
* @param domain Domain for which configuration applies.
|
||||
*/
|
||||
export function setLocaleData(data: any, domain?: string): void;
|
||||
|
||||
/**
|
||||
* Retrieve the translation of text.
|
||||
*
|
||||
* @see https://developer.wordpress.org/reference/functions/__/
|
||||
*
|
||||
* @param text Text to translate.
|
||||
* @param domain Domain to retrieve the translated text.
|
||||
*/
|
||||
export function __(text: string, domain?: string): string;
|
||||
|
||||
/**
|
||||
* Retrieve translated string with gettext context.
|
||||
*
|
||||
* @see https://developer.wordpress.org/reference/functions/_x/
|
||||
*
|
||||
* @param text Text to translate.
|
||||
* @param context Context information for the translators.
|
||||
* @param domain Domain to retrieve the translated text.
|
||||
*/
|
||||
export function _x(text: string, context: string, domain?: string): string;
|
||||
|
||||
/**
|
||||
* Translates and retrieves the singular or plural form based on the supplied
|
||||
* number.
|
||||
*
|
||||
* @see https://developer.wordpress.org/reference/functions/_n/
|
||||
*
|
||||
* @param single The text to be used if the number is singular.
|
||||
* @param plural The text to be used if the number is plural.
|
||||
* @param number The number to compare against to use either the
|
||||
* singular or plural form.
|
||||
* @param domain Domain to retrieve the translated text.
|
||||
*/
|
||||
export function _n(
|
||||
single: string,
|
||||
plural: string,
|
||||
n: number,
|
||||
domain?: string
|
||||
): string;
|
||||
|
||||
/**
|
||||
* Translates and retrieves the singular or plural form based on the supplied
|
||||
* number, with gettext context.
|
||||
*
|
||||
* @see https://developer.wordpress.org/reference/functions/_nx/
|
||||
*
|
||||
* @param single The text to be used if the number is singular.
|
||||
* @param plural The text to be used if the number is plural.
|
||||
* @param number The number to compare against to use either the
|
||||
* singular or plural form.
|
||||
* @param context Context information for the translators.
|
||||
* @param domain Domain to retrieve the translated text.
|
||||
*/
|
||||
export function _nx(
|
||||
single: string,
|
||||
plural: string,
|
||||
n: number,
|
||||
context: string,
|
||||
domain?: string
|
||||
): string;
|
||||
|
||||
/**
|
||||
* Returns a formatted string. If an error occurs in applying the format, the
|
||||
* original format string is returned.
|
||||
*
|
||||
* @param format The format of the string to generate.
|
||||
* @param args Arguments to apply to the format.
|
||||
*
|
||||
* @see http://www.diveintojavascript.com/projects/javascript-sprintf
|
||||
*/
|
||||
export function sprintf(format: string, ...args: any[]): string;
|
||||
19
types/wordpress__i18n/tsconfig.json
Normal file
19
types/wordpress__i18n/tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@wordpress/i18n": ["wordpress__i18n"]
|
||||
}
|
||||
},
|
||||
"files": ["index.d.ts", "wordpress__i18n-tests.ts"]
|
||||
}
|
||||
1
types/wordpress__i18n/tslint.json
Normal file
1
types/wordpress__i18n/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
4
types/wordpress__i18n/wordpress__i18n-tests.ts
Normal file
4
types/wordpress__i18n/wordpress__i18n-tests.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import * as i18n from "@wordpress/i18n";
|
||||
|
||||
i18n.sprintf(i18n._n("%d hat", "%d hats", 4, "text-domain"), 4); // 4 hats
|
||||
i18n.__("foobar", "foo-bar");
|
||||
Loading…
Reference in New Issue
Block a user