/**
 * Lightweight i18n module.
 *
 * Usage:
 *   import { t } from "../i18n/index.js";
 *   t("cmd.stop.sent", locale)              // no placeholders
 *   t("cmd.sleep.changed", locale, "10", "30")  // with placeholders
 *
 * The locale is typically read from `ownerConfig.language`.
 * Falls back to English when a locale or key is missing.
 */
import { messages, DEFAULT_LOCALE, SUPPORTED_LOCALES } from "./messages.js";
export { DEFAULT_LOCALE, SUPPORTED_LOCALES };
/**
 * Resolve a locale string (e.g. "zh-CN", "en-US", "zh") to a supported Locale.
 * Falls back to DEFAULT_LOCALE ("en") for unknown values.
 */
export function resolveLocale(raw) {
    if (!raw)
        return DEFAULT_LOCALE;
    const lower = raw.toLowerCase();
    if (lower.startsWith("zh"))
        return "zh";
    if (lower.startsWith("en"))
        return "en";
    return DEFAULT_LOCALE;
}
/**
 * Translate a message key into the given locale, substituting `{0}`, `{1}`, …
 * with the provided args.
 */
export function t(key, locale, ...args) {
    const entry = messages[key];
    let text = entry[locale];
    for (let i = 0; i < args.length; i++) {
        text = text.replaceAll(`{${i}}`, args[i]);
    }
    return text;
}
//# sourceMappingURL=index.js.map