amourlinguini
Version:
A JSON-based translation file manager.
74 lines (73 loc) • 3.4 kB
TypeScript
import { Categorized } from './models/categorized-location';
import { TypeMapper } from './models/internal-models';
declare type LinguiniOptions = {
/**
* Number of levels variables should be replaced.
* @defaultValue `10`
*/
replacementLevels: number;
/**
* Full path to a custom common language file.
*/
customCommonFile?: string;
};
export declare class Linguini {
private options;
private comData;
private langDatas;
/**
* Creates a new Linguini object to manage language files.
*
* @param folderPath - The folder path containing the language files.
* @param fileName - The base name of the language files to use. Note this should not include any file extensions or language codes. Ex: `lang`.
* @param options - Options to use for this Linguini setup.
*
* @returns A new Linguini object.
*/
constructor(folderPath: string, fileName: string, options?: Partial<LinguiniOptions>);
/**
* Returns an item from a language file, mapped to a type.
*
* @param location - The location of the item in the language file, using dot-notation, and relative to the "data" section in the JSON. Ex: `myCategory.myItem`.
* @param langCode - The language file code to extract from. Ex: `en`.
* @param typeMapper - A function which maps the retrieved item data to a type. The could be a built-in function from Linguini's `TypeMappers` import, or a custom function.
* @param variables - Any variables (Ex: `{{MY_VARIABLE}}`) to replace in the retrieved data.
*
* @returns The retrieved language file item.
*/
get<T>(location: string, langCode: string, typeMapper: TypeMapper<T>, variables?: Categorized): T;
/**
* Returns an item from a language file, as raw JSON.
*
* @param location - The location of the item in the language file, using dot-notation, and relative to the "data" section in the JSON. Ex: `myCategory.myItem`.
* @param langCode - The language file code to extract from. Ex: `en`.
* @param variables - Any variables (Ex: `{{MY_VARIABLE}}`) to replace in the retrieved data.
*
* @returns The retrieved language file item.
*/
getRaw(location: string, langCode: string, variables?: Categorized): any;
/**
* Returns a reference string from a language file.
*
* @param location - The location of the reference in the language file, using dot-notation, and relative to the "refs" section in the JSON. Ex: `myCategory.myItem`.
* @param langCode - The language file code to extract from. Ex: `en`.
* @param variables - Any variables (Ex: `{{MY_VARIABLE}}`) to replace in the retrieved data.
*
* @returns The retrieved language file reference string.
*/
getRef(location: string, langCode: string, variables?: {
[name: string]: string;
}): string;
/**
* Returns a common reference string from the common language file (*.common.json).
*
* @param location - The location of the reference in the common language file, using dot-notation. Ex: `myCategory.myItem`.
* @param variables - Any variables (Ex: `{{MY_VARIABLE}}`) to replace in the retrieved data.
*
* @returns The retrieved common reference string.
*/
getCom(location: string, variables?: {
[name: string]: string;
}): string;
}
export {};