UNPKG

svelte-i18n-lingui

Version:

Add i18n to Svelte/Sveltekit projects using Lingui, using message as the catalog id

75 lines (74 loc) 2.92 kB
export namespace locale { export { subscribe }; export function set(locale: any, messages: any): void; } /** * A Svelte store that subscribes to locale changes and returns a function that can be used to translate messages. * * Usage: * ```svelte * <script> * import { t } from 'svelte-i18n-lingui'; * </script> * * {$t`Hello World`} * ``` */ export const t: import("svelte/store").Readable<(descriptor: string | TemplateStringsArray | MessageDescriptor, ...args: (string | number)[]) => string>; /** * * @param {string | TemplateStringsArray | MessageDescriptor} descriptor - A tagged template literal, plain string, or a MessageDescriptor object. * @param {...string | number} args - additional arguments passed in to the tagged template literal, if any. * @returns {string} The message translated to the currently active locale. * */ export function gt(descriptor: string | TemplateStringsArray | MessageDescriptor, ...args: (string | number)[]): string; export function msg(descriptor: TemplateStringsArray | MessageDescriptor, ...args: string[]): string; export function msgPlural(variations: Record<string, string>): Record<string, string>; /** * A Svelte store that subscribes to locale changes and returns a function that can be used to translate pluralized messages. * * Usage: * ```svelte * <script> * import { plural } from 'svelte-i18n-lingui'; * * const count = 2 + 3; * </script> * * {$plural(count, { one: '# item', other: '# items' }) * ``` */ export const plural: import("svelte/store").Readable<(num: number, variations: Record<string, string>) => string>; /** * * @param {number} num - The number value to be used for pluralization. * @param {Record<string, string>} variations - a list of message variations for each plural form based on the locale. * @returns {string} The message translated to the currently active locale. * */ export function gPlural(num: number, variations: Record<string, string>): string; export { default as T } from "./T.svelte"; export { default as LegacyT } from "./LegacyT.svelte"; /** * MessageDescriptor object to describe a message with optional context and comment. */ export type MessageDescriptor = { /** * - The message to be translated. */ message: string; /** * - The context of the message, will be included in the po file. The same message with different context will be extracted as separate entries, and can be translated differently. */ context?: string; /** * - A comment purely for giving information to the translator, won't affect translated string. */ comment?: string; /** * - An optional dictionary of values to be used in the message. */ values?: Record<string, any>; }; declare const subscribe: (this: void, run: import("svelte/store").Subscriber<string>, invalidate?: () => void) => import("svelte/store").Unsubscriber;