package main
import (
"smesh.lol/web/common/jsbridge/localstorage"
)
const lsKeyLang = "smesh-lang"
var currentLang = "en"
// t returns the translated string for the given key in the current language.
func t(key string) string {
if m, ok := translations[currentLang]; ok {
if s, ok := m[key]; ok {
return s
}
}
// Fallback to English.
if s, ok := translations["en"][key]; ok {
return s
}
return key
}
func setLang(lang string) {
if _, ok := translations[lang]; !ok {
return
}
currentLang = lang
localstorage.SetItem(lsKeyLang, lang)
}
func initLang() {
saved := localstorage.GetItem(lsKeyLang)
if saved != "" {
if _, ok := translations[saved]; ok {
currentLang = saved
return
}
}
}
// countryToLang maps country codes to language codes.
func countryToLang(cc string) string {
switch cc {
case "JP":
return "ja"
case "BR", "PT", "AO", "MZ", "CV", "GW", "ST", "TL":
return "pt"
}
return "en"
}
var langNames = map[string]string{
"en": "English",
"ja": "日本語",
"pt": "Português",
}
var translations = map[string]map[string]string{
"en": {
// Login page.
"subtitle": "Sovereign Messaging, Encryption, Sync & Heuristics",
"login": "login with extension",
"requesting": "requesting...",
"install_signer": "install signer extension",
"err_no_ext": "extension not detected — install it first",
"err_no_id": "no identity — open signer to add one",
"req_fennec": "S.M.E.S.H. requires Fennec (Firefox) with the signer extension.",
"req_librewolf": "S.M.E.S.H. requires LibreWolf (or Firefox) with the signer extension.",
"get_fennec": "Get Fennec on F-Droid",
"dl_librewolf": "Download LibreWolf",
"chrome_why": "Chrome and Chrome based browsers force the use of complex and slow tooling and disrupts the parallel processing architecture of this app.",
"language": "Language",
"theme": "Theme",
"dark": "dark",
"light": "light",
// Top bar / nav.
"back": "\u2190 back",
"feed": "feed",
"messaging": "messaging",
"settings": "settings",
// Feed.
"connecting": "connecting...",
"show_more": "show more",
"show_less": "show less",
// Thread view.
"loading_thread": "loading thread...",
"thread_empty": "thread not found",
"replying_to": "replying to...",
// Profile.
"notes": "notes",
"follows": "follows",
"relays": "relays",
"mutes": "mutes",
"no_follows": "no follows data",
"no_relays": "no relay data",
"no_mutes": "no mutes data",
"following": "following",
"muted": "muted",
"copy": "copy",
"qr": "qr",
"message": "message",
"loading": "loading...",
"relay_info": "relay info",
"relay_fail": "failed to fetch relay info",
// Messaging.
"new_chat": "+ new chat",
"no_convos": "no conversations yet",
"npub_placeholder": "npub or hex pubkey",
"go": "go",
"msg_placeholder": "message...",
"send": "send",
"dm_notice": "encrypted DMs require the Smesh Signer extension",
"ratchet": "ratchet",
// About.
"developed_by": "developed by:",
"tagline": "Can Youse Paradigm?",
"about_donkey": "Every hour you don't zap, a donkey eats another cabbage. You can stop this. \U0001FABE",
// Settings.
"settings_title": "Settings",
"lang_label": "Interface language",
"theme_label": "Appearance",
// Signer.
"signer": "Signer",
"no_vault": "No vault found. Create a new one.",
"hd_keychain": "HD Keychain",
"vault_password": "Vault password",
"generate_keychain": "Generate New Keychain",
"generating": "Generating keychain...",
"create_failed": "Failed to create vault.",
"restore_seed": "Restore from Seed Phrase",
"seed_placeholder": "12-word seed phrase",
"account_placeholder": "Account number (default: 1)",
"restore_keychain": "Restore Keychain",
"restoring": "Restoring keychain...",
"restore_failed": "Invalid seed phrase or vault creation failed.",
"deriving_n": "Deriving identity",
"import_vault": "Import Vault File",
"choose_vault": "Choose Vault File...",
"vault_imported": "Vault imported. Unlock with your password.",
"invalid_vault": "Invalid vault file.",
"write_seed": "Write Down Your Seed Phrase",
"seed_warning": "This is the ONLY way to recover your identities. Write these words down and store them safely. They will not be shown again.",
"copy_clipboard": "Copy to Clipboard",
"copied": "Copied!",
"saved_it": "I've Saved It",
"vault_locked": "Vault is locked.",
"password": "Password",
"unlock": "Unlock",
"deriving_key": "Deriving key, this may take a minute...",
"wrong_password": "Wrong password.",
"identities": "Identities",
"nickname_placeholder": "Nickname for new identity",
"derive_new": "Derive New Identity",
"deriving": "Deriving...",
"show_seed": "Show Seed Phrase",
"export_vault": "Export Vault",
"lock_vault": "Lock Vault",
"reset_extension": "Reset Extension",
"reset_confirm": "This will erase all keys. Are you sure?",
"use": "Use",
"publish": "Publish",
"add": "Add",
},
"ja": {
"subtitle": "主権あるメッセージング、暗号化、同期 & ヒューリスティクス",
"login": "拡張機能でログイン",
"requesting": "リクエスト中...",
"install_signer": "署名拡張機能をインストール",
"err_no_ext": "拡張機能が検出されません — まずインストールしてください",
"err_no_id": "IDがありません — 署名拡張を開いて追加してください",
"req_fennec": "S.M.E.S.H.にはFennec(Firefox)と署名拡張が必要です。",
"req_librewolf": "S.M.E.S.H.にはLibreWolf(またはFirefox)と署名拡張が必要です。",
"get_fennec": "F-DroidでFennecを入手",
"dl_librewolf": "LibreWolfをダウンロード",
"chrome_why": "ChromeやChromiumベースのブラウザは複雑で遅いツールを強制し、このアプリの並列処理アーキテクチャを妨害します。",
"language": "言語",
"theme": "テーマ",
"dark": "ダーク",
"light": "ライト",
"back": "\u2190 戻る",
"feed": "フィード",
"messaging": "メッセージ",
"settings": "設定",
"connecting": "接続中...",
"show_more": "もっと見る",
"show_less": "閉じる",
"loading_thread": "スレッド読み込み中...",
"thread_empty": "スレッドが見つかりません",
"replying_to": "返信先...",
"notes": "ノート",
"follows": "フォロー",
"relays": "リレー",
"mutes": "ミュート",
"no_follows": "フォローデータなし",
"no_relays": "リレーデータなし",
"no_mutes": "ミュートデータなし",
"following": "フォロー中",
"muted": "ミュート中",
"copy": "コピー",
"qr": "QR",
"message": "メッセージ",
"loading": "読み込み中...",
"relay_info": "リレー情報",
"relay_fail": "リレー情報の取得に失敗しました",
"new_chat": "+ 新しいチャット",
"no_convos": "会話がまだありません",
"npub_placeholder": "npubまたは16進公開鍵",
"go": "実行",
"msg_placeholder": "メッセージ...",
"send": "送信",
"dm_notice": "暗号化DMにはSmesh Signer拡張が必要です",
"ratchet": "ラチェット",
"developed_by": "開発者:",
"tagline": "Can Youse Paradigm?",
"about_donkey": "zapしないと毎時間ロバがキャベツを食べてしまいます。止められるのはあなたです。\U0001FABE",
"settings_title": "設定",
"lang_label": "表示言語",
"theme_label": "外観",
"signer": "署名",
"no_vault": "金庫が見つかりません。新規作成してください。",
"hd_keychain": "HDキーチェーン",
"vault_password": "金庫のパスワード",
"generate_keychain": "新しいキーチェーンを生成",
"generating": "キーチェーン生成中...",
"create_failed": "金庫の作成に失敗しました。",
"restore_seed": "シードフレーズから復元",
"seed_placeholder": "12語のシードフレーズ",
"account_placeholder": "アカウント番号(デフォルト: 1)",
"restore_keychain": "キーチェーンを復元",
"restoring": "キーチェーン復元中...",
"restore_failed": "シードフレーズが無効か、金庫の作成に失敗しました。",
"deriving_n": "ID導出中",
"import_vault": "金庫ファイルをインポート",
"choose_vault": "金庫ファイルを選択...",
"vault_imported": "金庫をインポートしました。パスワードでロック解除してください。",
"invalid_vault": "無効な金庫ファイルです。",
"write_seed": "シードフレーズを書き留めてください",
"seed_warning": "これがIDを復元する唯一の方法です。これらの単語を書き留めて安全に保管してください。再表示されません。",
"copy_clipboard": "クリップボードにコピー",
"copied": "コピー済み!",
"saved_it": "保存しました",
"vault_locked": "金庫はロックされています。",
"password": "パスワード",
"unlock": "ロック解除",
"deriving_key": "鍵を導出中です。しばらくお待ちください...",
"wrong_password": "パスワードが違います。",
"identities": "ID一覧",
"nickname_placeholder": "新しいIDのニックネーム",
"derive_new": "新しいIDを導出",
"deriving": "導出中...",
"show_seed": "シードフレーズを表示",
"export_vault": "金庫をエクスポート",
"lock_vault": "金庫をロック",
"reset_extension": "拡張機能をリセット",
"reset_confirm": "すべての鍵が削除されます。よろしいですか?",
"use": "使用",
"publish": "公開",
"add": "追加",
},
"pt": {
"subtitle": "Mensagens Soberanas, Encriptação, Sincronização & Heurísticas",
"login": "entrar com extensão",
"requesting": "solicitando...",
"install_signer": "instalar extensão de assinatura",
"err_no_ext": "extensão não detectada — instale primeiro",
"err_no_id": "sem identidade — abra o signer para adicionar uma",
"req_fennec": "S.M.E.S.H. requer Fennec (Firefox) com a extensão de assinatura.",
"req_librewolf": "S.M.E.S.H. requer LibreWolf (ou Firefox) com a extensão de assinatura.",
"get_fennec": "Obter Fennec no F-Droid",
"dl_librewolf": "Baixar LibreWolf",
"chrome_why": "Navegadores baseados no Chrome forçam o uso de ferramentas complexas e lentas e interrompem a arquitetura de processamento paralelo deste aplicativo.",
"language": "Idioma",
"theme": "Tema",
"dark": "escuro",
"light": "claro",
"back": "\u2190 voltar",
"feed": "feed",
"messaging": "mensagens",
"settings": "configurações",
"connecting": "conectando...",
"show_more": "mostrar mais",
"show_less": "mostrar menos",
"loading_thread": "carregando thread...",
"thread_empty": "thread não encontrada",
"replying_to": "respondendo a...",
"notes": "notas",
"follows": "seguindo",
"relays": "relays",
"mutes": "silenciados",
"no_follows": "sem dados de seguidos",
"no_relays": "sem dados de relays",
"no_mutes": "sem dados de silenciados",
"following": "seguindo",
"muted": "silenciados",
"copy": "copiar",
"qr": "qr",
"message": "mensagem",
"loading": "carregando...",
"relay_info": "info do relay",
"relay_fail": "falha ao buscar info do relay",
"new_chat": "+ novo chat",
"no_convos": "nenhuma conversa ainda",
"npub_placeholder": "npub ou chave pública hex",
"go": "ir",
"msg_placeholder": "mensagem...",
"send": "enviar",
"dm_notice": "DMs encriptadas requerem a extensão Smesh Signer",
"ratchet": "ratchet",
"developed_by": "desenvolvido por:",
"tagline": "Can Youse Paradigm?",
"about_donkey": "A cada hora que você não dá zap, um burro come outro repolho. Você pode impedir isso. \U0001FABE",
"settings_title": "Configurações",
"lang_label": "Idioma da interface",
"theme_label": "Aparência",
"signer": "Assinador",
"no_vault": "Nenhum cofre encontrado. Crie um novo.",
"hd_keychain": "Chaveiro HD",
"vault_password": "Senha do cofre",
"generate_keychain": "Gerar Novo Chaveiro",
"generating": "Gerando chaveiro...",
"create_failed": "Falha ao criar cofre.",
"restore_seed": "Restaurar com Frase Semente",
"seed_placeholder": "Frase semente de 12 palavras",
"account_placeholder": "Número da conta (padrão: 1)",
"restore_keychain": "Restaurar Chaveiro",
"restoring": "Restaurando chaveiro...",
"restore_failed": "Frase semente inválida ou falha ao criar cofre.",
"deriving_n": "Derivando identidade",
"import_vault": "Importar Arquivo de Cofre",
"choose_vault": "Escolher Arquivo de Cofre...",
"vault_imported": "Cofre importado. Desbloqueie com sua senha.",
"invalid_vault": "Arquivo de cofre inválido.",
"write_seed": "Anote Sua Frase Semente",
"seed_warning": "Esta é a ÚNICA forma de recuperar suas identidades. Anote estas palavras e guarde-as em segurança. Elas não serão exibidas novamente.",
"copy_clipboard": "Copiar para Área de Transferência",
"copied": "Copiado!",
"saved_it": "Já Salvei",
"vault_locked": "Cofre está bloqueado.",
"password": "Senha",
"unlock": "Desbloquear",
"deriving_key": "Derivando chave, isso pode levar um minuto...",
"wrong_password": "Senha incorreta.",
"identities": "Identidades",
"nickname_placeholder": "Apelido para nova identidade",
"derive_new": "Derivar Nova Identidade",
"deriving": "Derivando...",
"show_seed": "Mostrar Frase Semente",
"export_vault": "Exportar Cofre",
"lock_vault": "Bloquear Cofre",
"reset_extension": "Redefinir Extensão",
"reset_confirm": "Isso apagará todas as chaves. Tem certeza?",
"use": "Usar",
"publish": "Publicar",
"add": "Adicionar",
},
}