// 中英文界面文案
import { createContext, useContext, type ReactNode } from 'react';
import type { Language } from './types';
const zh = {
appName: 'xmail',
brandTagline: '多邮箱统一管理',
loginTitle: '登录 xmail',
loginSubtitle: '统一管理你的所有邮箱',
username: '用户名',
password: '密码',
signIn: '登录',
signingIn: '登录中…',
loginTip: '账号由管理员创建,暂不开放自助注册',
logout: '退出登录',
cancel: '取消',
save: '保存',
saving: '保存中…',
saved: '已保存',
saveFailed: '保存失败',
delete: '删除',
close: '关闭',
confirm: '确定',
edit: '编辑',
test: '测试',
testing: '测试中…',
loading: '加载中…',
all: '全部',
back: '返回',
optional: '可选',
unknown: '未知',
deleteConfirm: '确定要删除吗?',
folderInbox: '收件箱',
folderSent: '已发送',
folderDrafts: '草稿',
folderTrash: '垃圾箱',
compose: '写邮件',
searchPlaceholder: '搜索邮件…',
noMessages: '这里还没有邮件',
noSearchResults: '没有找到相关邮件',
selectMail: '选择一封邮件开始阅读',
selectMailHint: '邮件内容将显示在这里',
syncNow: '同步',
syncing: '同步中…',
syncDone: '同步完成,新增 {n} 封邮件',
syncFailed: '同步失败',
settings: '设置',
allAccounts: '全部邮箱',
accountFilter: '账号:{name}',
from: '发件人',
to: '收件人',
cc: '抄送',
bcc: '密送',
subject: '主题',
writeMessage: '撰写新邮件',
send: '发送',
sending: '发送中…',
sendOk: '邮件已发送',
saveDraft: '保存草稿',
draftSaved: '草稿已保存',
attachments: '附件',
addAttachment: '添加附件',
download: '下载',
noSubject: '(无主题)',
deletedToTrash: '已移到垃圾箱',
restored: '已恢复',
permanentlyDeleted: '已永久删除',
moveToTrash: '移到垃圾箱',
deleteForever: '永久删除',
deleteMailConfirm: '确定要永久删除这封邮件吗?此操作不可恢复。',
restore: '恢复',
unread: '未读',
messageCount: '共 {n} 封',
noAccountsTitle: '还没有邮箱账号',
noAccountsHint: '先添加一个邮箱账号,才能接收和发送邮件',
goToAccounts: '去添加账号',
attachmentTooLarge: '附件总大小不能超过 25MB',
loadMore: '加载更多',
loadingMore: '加载中…',
noRecipientError: '请填写收件人',
selectAccountError: '请选择发件账号',
draftEditHint: '正在编辑草稿',
searchInFolder: '在「{folder}」中搜索',
clearFilter: '清除筛选',
refresh: '刷新',
markUnread: '标为未读',
markRead: '标为已读',
mailActions: '邮件操作',
openMail: '打开邮件',
editDraft: '编辑草稿',
retry: '重试',
folderSyncErrorTitle: '邮箱同步失败',
folderSyncErrorHint: '请检查邮箱配置或网络后重试',
selectMode: '选择',
selectAll: '全选',
selectedCount: '已选 {n} 封',
batchUpdated: '已更新 {n} 封邮件',
noUnreadMessages: '没有未读邮件',
noUnreadHint: '当前文件夹中的邮件都已阅读',
settingsTitle: '设置',
navAppearance: '外观',
navAccounts: '邮箱账号管理',
navBackup: '备份设置',
navEditor: '编辑器',
navAccount: '账户',
navSync: '同步',
navNotifications: '通知',
navAbout: '关于',
appearanceTitle: '外观',
appearanceDesc: '调整界面语言、主题与排版,所有设置仅对当前账号生效。',
language: '界面语言',
languageZh: '中文',
languageEn: 'English',
theme: '主题',
themeLight: '亮色',
themeDark: '暗色',
themeSystem: '跟随系统',
accentColor: '强调色',
density: '界面密度',
densityComfortable: '舒适',
densityCompact: '紧凑',
bodyFont: '正文字体',
fontSans: '无衬线',
fontSerif: '衬线',
fontSize: '字号',
lineHeight: '行高',
contentWidth: '内容宽度',
widthNarrow: '窄',
widthStandard: '标准',
widthWide: '宽',
widthFull: '满',
appearancePreview: '预览',
previewSubject: '来自 xmail 的问候',
previewBody: '这是一封用于预览排版效果的示例邮件。调整字号、行高和内容宽度,可以实时看到阅读体验的变化。',
previewSender: 'xmail 团队',
accountsTitle: '邮箱账号管理',
accountsDesc: '添加需要统一管理的邮箱。密码使用 AES-256 加密保存,不会明文存储。',
addAccount: '添加邮箱账号',
editAccount: '编辑邮箱账号',
noAccounts: '暂未添加邮箱账号',
accountName: '账号名称',
accountNameHint: '仅用于界面展示,如「工作邮箱」',
emailAddress: '邮箱地址',
mailboxUser: '登录用户名',
mailboxPassword: '密码 / 授权码',
passwordKeep: '留空则保持不变',
imapServer: 'IMAP 服务器',
smtpServer: 'SMTP 服务器',
host: '服务器地址',
port: '端口',
secure: 'SSL/TLS',
testConnection: '测试连接',
testOk: '连接正常',
testPartial: '部分连接失败',
imapOk: 'IMAP 连接成功',
smtpOk: 'SMTP 连接成功',
deleteAccountConfirm: '确定删除账号「{name}」吗?该账号下已同步的邮件也会一并删除。',
lastSync: '上次同步:{time}',
neverSynced: '尚未同步',
accountSaved: '账号已保存',
accountDeleted: '账号已删除',
accountSyncDone: '同步完成,新增 {n} 封',
fillRequired: '请填写完整的账号信息',
colorTag: '颜色标记',
presetServers: '常用邮箱',
presetCustom: '自定义',
backupTitle: '备份设置',
backupDesc: '将完整数据快照备份到 WebDAV(坚果云、Nextcloud 等),支持手动与定时备份。',
webdavUrl: 'WebDAV 地址',
webdavRequired: '请先填写 WebDAV 地址',
webdavUser: 'WebDAV 用户名',
webdavPass: 'WebDAV 密码',
webdavPassSaved: '已保存密码,留空则不修改',
webdavPassKeep: '未设置密码',
remotePath: '远程目录',
remotePathHint: '备份文件将保存到该目录,不存在时会自动创建',
testWebdav: '测试连接',
webdavOk: '连接成功,目录内已有 {n} 个文件',
autoBackup: '定时自动备份',
backupInterval: '备份间隔',
hours: '小时',
includeBodies: '包含邮件正文',
includeAttachments: '包含附件',
backupRange: '邮件时间范围',
days: '天',
accountScope: '备份账号范围',
backupNow: '立即备份',
backingUp: '备份中…',
backupOk: '备份完成:{file}',
lastBackup: '上次备份:{time}',
never: '从未',
restoreTitle: '从 WebDAV 恢复',
restoreDesc: '恢复前会自动做一次本地安全备份(保留最近 8 份),可从数据目录的 local-backups 找回。',
loadFiles: '读取备份列表',
noBackupFiles: '未找到备份文件',
restoreMode: '恢复内容',
restoreConfig: '仅恢复配置',
restoreConfigHint: '邮箱账号、WebDAV 设置、外观等用户设置',
restoreFull: '配置 + 邮件',
restoreFullHint: '在配置基础上,恢复备份中包含的邮件与附件',
restoreBtn: '开始恢复',
restoreConfirm: '恢复会覆盖当前账号的邮箱配置与设置(完整模式还会覆盖本地邮件),确定继续吗?',
restoreOk: '恢复完成:{accounts} 个账号、{messages} 封邮件、{attachments} 个附件',
restoreConfigOk: '配置恢复完成:{accounts} 个账号,本地邮件保持不变',
safetyBackup: '本地安全备份:{file}',
selectFile: '请选择要恢复的备份文件',
backupNote: '「包含邮件正文」与「包含附件」决定备份体积;关闭正文时仅备份账号与设置。',
editorTitle: '编辑器',
editorDesc: '设置写信时的默认签名与正文排版。',
signature: '邮件签名',
signatureHint: '撰写新邮件时自动添加到正文末尾',
editorFont: '编辑器字体',
defaultAccount: '默认发件账号',
noDefaultAccount: '不指定(使用第一个账号)',
editorFontSize: '编辑字号',
editorLineHeight: '编辑行高',
accountTitle: '账户',
accountDesc: '管理当前登录账号的密码与管理员用户。',
accountInfo: '账号信息',
usernameLabel: '用户名',
role: '角色',
roleAdmin: '管理员',
roleUser: '普通用户',
changePassword: '修改密码',
currentPassword: '当前密码',
newPassword: '新密码',
confirmPassword: '确认新密码',
passwordMismatch: '两次输入的新密码不一致',
passwordChanged: '密码已修改',
userManageTitle: '用户管理',
userManageDesc: '创建、停用账号或重置密码。用户之间的数据完全隔离。',
createUser: '创建用户',
newUsername: '用户名',
initialPassword: '初始密码',
create: '创建',
disable: '停用',
enable: '启用',
disabledTag: '已停用',
adminTag: '管理员',
userTag: '用户',
resetPassword: '重置密码',
resetPasswordFor: '为用户「{name}」设置新密码',
resetOk: '密码已重置',
userCreated: '用户已创建',
createdAt: '创建时间',
syncTitle: '同步',
syncDesc: '配置 IMAP 增量同步的范围与频率,邮件会保存到本地数据库供快速检索。',
autoSync: '自动同步',
syncInterval: '同步间隔',
minutes: '分钟',
syncRange: '同步时间范围',
syncRangeHint: '首次同步会拉取该时间范围内的邮件',
folderLimit: '单文件夹同步上限',
folderLimitHint: '每次最多拉取的邮件数量,避免首次同步耗时过长',
syncAllBtn: '立即同步全部邮箱',
syncStatusTitle: '同步状态',
syncRunning: '同步进行中…',
syncDoneCount: '同步完成,新增 {n} 封邮件',
lastSyncLabel: '上次同步',
syncErrorLabel: '错误',
noSyncAccounts: '还没有邮箱账号',
syncAlreadyRunning: '同步任务正在进行中,请稍候',
notificationsTitle: '通知',
notificationsDesc: '配置 Telegram 机器人,新邮件同步后自动推送提醒。',
telegramTitle: 'Telegram 机器人',
telegramEnable: '新邮件推送',
telegramEnableHint: '开启后,新邮件同步入库时会推送到指定会话',
botToken: 'Bot Token',
botTokenHint: '通过 @BotFather 创建机器人后获取',
chatId: 'Chat ID',
chatIdHint: '你的用户 ID 或群组 ID(群组通常以 -100 开头)',
telegramCredentialsHint: '凭据加密存储,保存后页面不会回显已保存内容',
telegramConfigured: '已配置',
telegramNotSet: '未配置',
saveTelegram: '保存配置',
telegramSaved: 'Telegram 配置已保存',
telegramNotConfigured: '请先填写并保存 Bot Token 与 Chat ID',
sendTestMessage: '发送测试消息',
sendingTest: '发送中…',
telegramTestSent: '测试消息已发送,请查看 Telegram',
telegramStepsTitle: '如何获取 Chat ID',
telegramSteps:
'在 Telegram 中搜索你的机器人并发送一条消息,然后访问 https://api.telegram.org/bot<你的TOKEN>/getUpdates 查看 chat.id。',
menu: '菜单',
aboutTitle: '关于',
aboutDesc: 'xmail 是一个可自托管的多邮箱统一管理平台。',
version: '版本',
techStack: '技术栈',
techStackValue: 'Node.js · Express · SQLite · React · Vite · TypeScript',
dataTitle: '数据与隐私',
dataDesc: '所有邮件、账号与配置都保存在你自己的服务器上,密码使用 AES-256-GCM 加密存储。',
securityTitle: '安全建议',
securityDesc:
'请定期通过 WebDAV 备份数据,并妥善保管数据目录中的 secret.key(或 APP_SECRET),否则已加密的密码将无法解密。',
aboutFooter: '为自托管而设计',
requestFailed: '请求失败',
networkError: '网络异常,请检查服务是否正常运行',
};
export type I18nKey = keyof typeof zh;
const en: Record<I18nKey, string> = {
appName: 'xmail',
brandTagline: 'All your mailboxes, one place',
loginTitle: 'Sign in to xmail',
loginSubtitle: 'Manage all your mailboxes in one place',
username: 'Username',
password: 'Password',
signIn: 'Sign in',
signingIn: 'Signing in…',
loginTip: 'Accounts are created by the administrator. Self sign-up is disabled.',
logout: 'Sign out',
cancel: 'Cancel',
save: 'Save',
saving: 'Saving…',
saved: 'Saved',
saveFailed: 'Failed to save',
delete: 'Delete',
close: 'Close',
confirm: 'Confirm',
edit: 'Edit',
test: 'Test',
testing: 'Testing…',
loading: 'Loading…',
all: 'All',
back: 'Back',
optional: 'optional',
unknown: 'Unknown',
deleteConfirm: 'Are you sure you want to delete this?',
folderInbox: 'Inbox',
folderSent: 'Sent',
folderDrafts: 'Drafts',
folderTrash: 'Trash',
compose: 'Compose',
searchPlaceholder: 'Search mail…',
noMessages: 'No messages here yet',
noSearchResults: 'No matching messages',
selectMail: 'Select a message to read',
selectMailHint: 'The message will be shown here',
syncNow: 'Sync',
syncing: 'Syncing…',
syncDone: 'Sync complete, {n} new message(s)',
syncFailed: 'Sync failed',
settings: 'Settings',
allAccounts: 'All mailboxes',
accountFilter: 'Account: {name}',
from: 'From',
to: 'To',
cc: 'Cc',
bcc: 'Bcc',
subject: 'Subject',
writeMessage: 'New message',
send: 'Send',
sending: 'Sending…',
sendOk: 'Message sent',
saveDraft: 'Save draft',
draftSaved: 'Draft saved',
attachments: 'Attachments',
addAttachment: 'Add attachment',
download: 'Download',
noSubject: '(no subject)',
deletedToTrash: 'Moved to trash',
restored: 'Restored',
permanentlyDeleted: 'Permanently deleted',
moveToTrash: 'Move to trash',
deleteForever: 'Delete forever',
deleteMailConfirm: 'Permanently delete this message? This cannot be undone.',
restore: 'Restore',
unread: 'unread',
messageCount: '{n} messages',
noAccountsTitle: 'No mailbox yet',
noAccountsHint: 'Add a mailbox account before receiving or sending mail',
goToAccounts: 'Add an account',
attachmentTooLarge: 'Total attachment size cannot exceed 25MB',
loadMore: 'Load more',
loadingMore: 'Loading…',
noRecipientError: 'Please enter at least one recipient',
selectAccountError: 'Please select a sending account',
draftEditHint: 'Editing draft',
searchInFolder: 'Search in “{folder}”',
clearFilter: 'Clear filter',
refresh: 'Refresh',
markUnread: 'Mark as unread',
markRead: 'Mark as read',
mailActions: 'Mail actions',
openMail: 'Open message',
editDraft: 'Edit draft',
retry: 'Retry',
folderSyncErrorTitle: 'Mailbox sync failed',
folderSyncErrorHint: 'Check the mailbox settings or network connection, then try again',
selectMode: 'Select',
selectAll: 'Select all',
selectedCount: '{n} selected',
batchUpdated: 'Updated {n} message(s)',
noUnreadMessages: 'No unread messages',
noUnreadHint: 'All messages in this folder have been read',
settingsTitle: 'Settings',
navAppearance: 'Appearance',
navAccounts: 'Mailbox accounts',
navBackup: 'Backup',
navEditor: 'Composer',
navAccount: 'Account',
navSync: 'Sync',
navNotifications: 'Notifications',
navAbout: 'About',
appearanceTitle: 'Appearance',
appearanceDesc: 'Customize language, theme and typography. These settings only affect your account.',
language: 'Language',
languageZh: '中文',
languageEn: 'English',
theme: 'Theme',
themeLight: 'Light',
themeDark: 'Dark',
themeSystem: 'System',
accentColor: 'Accent color',
density: 'Density',
densityComfortable: 'Comfortable',
densityCompact: 'Compact',
bodyFont: 'Body font',
fontSans: 'Sans-serif',
fontSerif: 'Serif',
fontSize: 'Font size',
lineHeight: 'Line height',
contentWidth: 'Content width',
widthNarrow: 'Narrow',
widthStandard: 'Standard',
widthWide: 'Wide',
widthFull: 'Full',
appearancePreview: 'Preview',
previewSubject: 'A note from xmail',
previewBody:
'This sample message shows how mail looks while reading. Adjust the font size, line height and content width to preview the reading experience.',
previewSender: 'The xmail team',
accountsTitle: 'Mailbox accounts',
accountsDesc: 'Add mailboxes to manage. Passwords are encrypted with AES-256, never stored in plain text.',
addAccount: 'Add mailbox',
editAccount: 'Edit mailbox',
noAccounts: 'No mailbox accounts yet',
accountName: 'Account name',
accountNameHint: 'For display only, e.g. “Work mail”',
emailAddress: 'Email address',
mailboxUser: 'Username',
mailboxPassword: 'Password / app password',
passwordKeep: 'Leave blank to keep current password',
imapServer: 'IMAP server',
smtpServer: 'SMTP server',
host: 'Host',
port: 'Port',
secure: 'SSL/TLS',
testConnection: 'Test connection',
testOk: 'Connection OK',
testPartial: 'Partial failure',
imapOk: 'IMAP connection OK',
smtpOk: 'SMTP connection OK',
deleteAccountConfirm:
'Delete account “{name}”? All synced messages of this account will be deleted as well.',
lastSync: 'Last synced: {time}',
neverSynced: 'Never synced',
accountSaved: 'Account saved',
accountDeleted: 'Account deleted',
accountSyncDone: 'Sync complete, {n} new message(s)',
fillRequired: 'Please fill in all account fields',
colorTag: 'Color',
presetServers: 'Common providers',
presetCustom: 'Custom',
backupTitle: 'Backup',
backupDesc:
'Back up a full data snapshot to WebDAV (Jianguoyun, Nextcloud, etc.). Manual and scheduled backups are supported.',
webdavUrl: 'WebDAV URL',
webdavRequired: 'Please enter the WebDAV URL first',
webdavUser: 'WebDAV username',
webdavPass: 'WebDAV password',
webdavPassSaved: 'Password saved, leave blank to keep it',
webdavPassKeep: 'Not set',
remotePath: 'Remote folder',
remotePathHint: 'Backups are stored here; the folder is created automatically if missing',
testWebdav: 'Test connection',
webdavOk: 'Connected. {n} file(s) in the folder',
autoBackup: 'Scheduled backup',
backupInterval: 'Interval',
hours: 'hours',
includeBodies: 'Include message bodies',
includeAttachments: 'Include attachments',
backupRange: 'Message time range',
days: 'days',
accountScope: 'Accounts to back up',
backupNow: 'Back up now',
backingUp: 'Backing up…',
backupOk: 'Backup complete: {file}',
lastBackup: 'Last backup: {time}',
never: 'Never',
restoreTitle: 'Restore from WebDAV',
restoreDesc:
'A local safety backup is created before restoring (latest 8 kept), available in the local-backups folder of the data directory.',
loadFiles: 'Load backup files',
noBackupFiles: 'No backup files found',
restoreMode: 'Restore',
restoreConfig: 'Configuration only',
restoreConfigHint: 'Mailbox accounts, WebDAV settings, appearance and other user settings',
restoreFull: 'Configuration + mail',
restoreFullHint: 'Configuration plus messages and attachments contained in the backup',
restoreBtn: 'Restore now',
restoreConfirm:
'Restoring overwrites the mailbox configuration and settings of this account (full mode also overwrites local mail). Continue?',
restoreOk: 'Restored {accounts} account(s), {messages} message(s), {attachments} attachment(s)',
restoreConfigOk: 'Configuration restored: {accounts} account(s). Local mail is unchanged.',
safetyBackup: 'Local safety backup: {file}',
selectFile: 'Select a backup file to restore',
backupNote:
'Bodies and attachments determine the backup size. With bodies disabled only accounts and settings are backed up.',
editorTitle: 'Composer',
editorDesc: 'Set the default signature and text layout when composing.',
signature: 'Email signature',
signatureHint: 'Appended automatically to new messages',
editorFont: 'Composer font',
defaultAccount: 'Default sending account',
noDefaultAccount: 'Not specified (use the first account)',
editorFontSize: 'Composer font size',
editorLineHeight: 'Composer line height',
accountTitle: 'Account',
accountDesc: 'Manage your password and, for administrators, platform users.',
accountInfo: 'Account information',
usernameLabel: 'Username',
role: 'Role',
roleAdmin: 'Administrator',
roleUser: 'User',
changePassword: 'Change password',
currentPassword: 'Current password',
newPassword: 'New password',
confirmPassword: 'Confirm new password',
passwordMismatch: 'The new passwords do not match',
passwordChanged: 'Password changed',
userManageTitle: 'User management',
userManageDesc: 'Create, disable accounts or reset passwords. Data is fully isolated between users.',
createUser: 'Create user',
newUsername: 'Username',
initialPassword: 'Initial password',
create: 'Create',
disable: 'Disable',
enable: 'Enable',
disabledTag: 'Disabled',
adminTag: 'Admin',
userTag: 'User',
resetPassword: 'Reset password',
resetPasswordFor: 'Set a new password for “{name}”',
resetOk: 'Password reset',
userCreated: 'User created',
createdAt: 'Created at',
syncTitle: 'Sync',
syncDesc:
'Configure the range and frequency of incremental IMAP sync. Mail is stored locally for fast search.',
autoSync: 'Automatic sync',
syncInterval: 'Interval',
minutes: 'minutes',
syncRange: 'Sync time range',
syncRangeHint: 'The first sync fetches messages within this range',
folderLimit: 'Per-folder limit',
folderLimitHint: 'Maximum messages fetched per run to keep the first sync fast',
syncAllBtn: 'Sync all mailboxes now',
syncStatusTitle: 'Sync status',
syncRunning: 'Sync in progress…',
syncDoneCount: 'Sync complete, {n} new message(s)',
lastSyncLabel: 'Last sync',
syncErrorLabel: 'Error',
noSyncAccounts: 'No mailbox accounts yet',
syncAlreadyRunning: 'A sync is already running, please wait',
notificationsTitle: 'Notifications',
notificationsDesc: 'Connect a Telegram bot to receive new mail alerts after sync.',
telegramTitle: 'Telegram bot',
telegramEnable: 'New mail alerts',
telegramEnableHint: 'When enabled, new mail is pushed to the configured chat after sync',
botToken: 'Bot Token',
botTokenHint: 'Create a bot with @BotFather and copy its token',
chatId: 'Chat ID',
chatIdHint: 'Your user ID or group ID (groups usually start with -100)',
telegramCredentialsHint: 'Credentials are encrypted and never shown again after saving',
telegramConfigured: 'Configured',
telegramNotSet: 'Not configured',
saveTelegram: 'Save configuration',
telegramSaved: 'Telegram configuration saved',
telegramNotConfigured: 'Please fill in and save both Bot Token and Chat ID first',
sendTestMessage: 'Send test message',
sendingTest: 'Sending…',
telegramTestSent: 'Test message sent, please check Telegram',
telegramStepsTitle: 'How to get your Chat ID',
telegramSteps:
'Search for your bot in Telegram and send it a message, then open https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates and read chat.id.',
menu: 'Menu',
aboutTitle: 'About',
aboutDesc: 'xmail is a self-hosted multi-mailbox management platform.',
version: 'Version',
techStack: 'Tech stack',
techStackValue: 'Node.js · Express · SQLite · React · Vite · TypeScript',
dataTitle: 'Data & privacy',
dataDesc:
'All messages, accounts and settings live on your own server. Passwords are encrypted with AES-256-GCM.',
securityTitle: 'Security note',
securityDesc:
'Back up regularly via WebDAV and keep secret.key (or APP_SECRET) safe, otherwise encrypted passwords cannot be decrypted.',
aboutFooter: 'Built for self-hosting',
requestFailed: 'Request failed',
networkError: 'Network error. Please check whether the service is running',
};
const dictionaries: Record<Language, Record<I18nKey, string>> = { zh, en };
const I18nContext = createContext<{
lang: Language;
t: (key: I18nKey, vars?: Record<string, string | number>) => string;
}>({
lang: 'zh',
t: (key) => zh[key] || key,
});
export function I18nProvider({ lang, children }: { lang: Language; children: ReactNode }) {
const dictionary = dictionaries[lang] || zh;
const t = (key: I18nKey, vars?: Record<string, string | number>) => {
let text = dictionary[key] || zh[key] || key;
if (vars) {
for (const [name, value] of Object.entries(vars)) {
text = text.replaceAll(`{${name}}`, String(value));
}
}
return text;
};
return <I18nContext.Provider value={{ lang, t }}>{children}</I18nContext.Provider>;
}
export function useI18n() {
return useContext(I18nContext);
}