diff options
Diffstat (limited to 'src/i18n')
| -rw-r--r-- | src/i18n/en.json | 4 | ||||
| -rw-r--r-- | src/i18n/eo.json | 2 | ||||
| -rw-r--r-- | src/i18n/messages.js | 26 | ||||
| -rw-r--r-- | src/i18n/zh.json | 49 |
4 files changed, 73 insertions, 8 deletions
diff --git a/src/i18n/en.json b/src/i18n/en.json index ca022c82..c8de6851 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -339,6 +339,10 @@ "select_all": "Select all" }, "settings": { + "add_language": "Add fallback language", + "remove_language": "Remove", + "primary_language": "Primary language:", + "fallback_language": "Fallback language {index}:", "app_name": "App name", "expert_mode": "Show advanced", "save": "Save changes", diff --git a/src/i18n/eo.json b/src/i18n/eo.json index 3596065c..e013edee 100644 --- a/src/i18n/eo.json +++ b/src/i18n/eo.json @@ -603,7 +603,7 @@ "use_websockets": "Uzi teĥnikaron «websockets» (tuja ĝisdatigo)", "mention_link_display_full_for_remote": "plene nur je uzantoj foraj (ekz. {'@'}zozo{'@'}ekzemplo.org)", "expert_mode": "Montri altnivelajn", - "setting_server_side": "Ĉi tiu agordo estas ligita al via profilo, kaj efektiviĝon en ĉiuj viaj salutoj kaj klientoj", + "setting_server_side": "Ĉi tiu agordo estas ligita al via profilo, kaj efektiviĝos en ĉiuj viaj salutoj kaj klientoj", "post_look_feel": "Aspekto de afiŝoj", "mention_links": "Menciaj ligiloj", "email_language": "Lingvo de leteroj ricevotaj de la servilo", diff --git a/src/i18n/messages.js b/src/i18n/messages.js index 74a89ca8..849d98fd 100644 --- a/src/i18n/messages.js +++ b/src/i18n/messages.js @@ -7,8 +7,11 @@ // sed -i -e "s/'//gm" -e 's/"/\\"/gm' -re 's/^( +)(.+?): ((.+?))?(,?)(\{?)$/\1"\2": "\4"/gm' -e 's/\"\{\"/{/g' -e 's/,"$/",/g' file.json // There's only problem that apostrophe character ' gets replaced by \\ so you have to fix it manually, sorry. +import { isEqual } from 'lodash' import { languages, langCodeToJsonName } from './languages.js' +const ULTIMATE_FALLBACK_LOCALE = 'en' + const hasLanguageFile = (code) => languages.includes(code) const loadLanguageFile = (code) => { @@ -25,11 +28,26 @@ const messages = { en: require('./en.json').default }, setLanguage: async (i18n, language) => { - if (hasLanguageFile(language)) { - const messages = await loadLanguageFile(language) - i18n.setLocaleMessage(language, messages.default) + const languages = (Array.isArray(language) ? language : [language]).filter(k => k) + + if (!languages.includes(ULTIMATE_FALLBACK_LOCALE)) { + languages.push(ULTIMATE_FALLBACK_LOCALE) + } + const [first, ...rest] = languages + + if (first === i18n.locale && isEqual(rest, i18n.fallbackLocale)) { + return } - i18n.locale = language + + for (const lang of languages) { + if (hasLanguageFile(lang)) { + const messages = await loadLanguageFile(lang) + i18n.setLocaleMessage(lang, messages.default) + } + } + + i18n.fallbackLocale = rest + i18n.locale = first } } diff --git a/src/i18n/zh.json b/src/i18n/zh.json index cf5f384c..8f0b04bd 100644 --- a/src/i18n/zh.json +++ b/src/i18n/zh.json @@ -53,7 +53,13 @@ "direct": "私讯", "private": "仅关注者", "unlisted": "列外" - } + }, + "scroll_to_top": "滚动至顶", + "generic_error_message": "发生一个错误:{0}", + "never_show_again": "不再显示", + "undo": "撤销", + "yes": "是", + "no": "否" }, "image_cropper": { "crop_picture": "裁剪图片", @@ -109,7 +115,12 @@ "chats": "聊天", "timelines": "时间线", "bookmarks": "书签", - "home_timeline": "主页时间线" + "home_timeline": "主页时间线", + "lists": "列表", + "edit_finish": "完成编辑", + "mobile_notifications": "打开通知(有未读的)", + "mobile_notifications_close": "关闭通知", + "announcements": "公告" }, "notifications": { "broken_favorite": "未知的状态,正在搜索中…", @@ -890,7 +901,18 @@ "search_emoji": "搜索表情符号", "emoji": "表情符号", "load_all": "加载所有表情符号(共 {emojiAmount} 个)", - "load_all_hint": "最先加载的 {saneAmount} 表情符号,加载全部表情符号可能会带来性能问题。" + "load_all_hint": "最先加载的 {saneAmount} 表情符号,加载全部表情符号可能会带来性能问题。", + "unicode_groups": { + "flags": "旗帜", + "food-and-drink": "饮食", + "objects": "物件", + "people-and-body": "人和身体", + "symbols": "符号", + "travel-and-places": "旅行和地点", + "activities": "活动", + "animals-and-nature": "动物和自然" + }, + "regional_indicator": "地区指示符 {letter}" }, "about": { "mrf": { @@ -958,5 +980,26 @@ "delete": "删除", "message_user": "发消息给 {nickname}", "you": "你:" + }, + "announcements": { + "page_header": "公告", + "title": "公告", + "mark_as_read_action": "标为已读", + "post_form_header": "发布公告", + "post_placeholder": "在这里输入公告内容...", + "post_action": "发布", + "post_error": "错误:{error}", + "close_error": "关闭", + "delete_action": "删除", + "start_time_prompt": "起始时间: ", + "end_time_prompt": "终止时间: ", + "all_day_prompt": "这是全天的事件", + "published_time_display": "发表于 {time}", + "start_time_display": "开始于 {time}", + "end_time_display": "结束于 {time}", + "edit_action": "编辑", + "submit_edit_action": "提交", + "cancel_edit_action": "取消", + "inactive_message": "这个公告不活跃" } } |
