import { AxiosResponse } from 'axios'; import { App, Ref } from 'vue'; export type Locale = string; export interface LanguageOption { /** * ISO 639-1 language code (e.g., "en" for English, "fr" for French). */ isoCode?: string; /** * The name of the language in English (e.g., "English", "Français"). */ name: string; /** * The URL of the country's flag image. * Flags are sourced from https://flagcdn.com and are typically in SVG format for high-quality resolution. */ flag?: string; } export interface I18n { /** * Locale message translation * * @param key - The translation key * @param params - A values of named interpolation * @param args - Positional interpolation values * * @returns translation message * @example `t('Hello {user}!', { user: 'John Doe' })` - returns: 'Hello John Doe!' * @example `t('Hello %s! I am %s.', "John Doe", "Peter Smith")` - returns: 'Hello John Doe! I am Peter Smith.' */ t: { (key: string, params: Record): string; (key: string, ...args: (string | number | boolean)[]): string; }; /** * Change the locale dynamically * * @param newLocale - The locale to switch to */ setLocale: (newLocale: Locale) => Promise; /** * Get the current locale * * @returns Current locale */ locale: Ref; /** * Service methods handle fetch requests */ service?: I18nService; } type MessageMap = Record; export interface I18nService { /** * Fetch all translation messages for a specific locale. * @param locale The locale code (e.g., 'en', 'id'). * @returns A promise resolving to a key-value record of messages. */ getMessages(locale: string): Promise< AxiosResponse<{ data: MessageMap; }> >; /** * Fetch all available lang options for LanguageDropdown and LanguageSwitcher * * @returns Promise Array of options */ getLanguageOptions(): Promise; /** * Fetch single lang option meta data * * @param locale The locale code (e.g., 'en', 'id'). * @returns Promise LanguageMeta */ getLanguageOptionMeta(locale: string): Promise; /** * Translate a specific text to the target locale. * @param key Unique translation key. * @param locale Target locale code. * @returns A promise resolving to the translated string. */ translateText(key: string, locale: string): Promise; } export declare const useI18n: () => I18n; declare const i18n: { install: (app: App) => void; }; export declare const createI18nWithExtension: ( service: I18nService, ) => typeof i18n; export default i18n; declare module 'vue' { interface ComponentCustomProperties { $i18n: I18n; $t: I18n['t']; } } declare global { interface Window { i18n: I18n; } }