From 74a482992f5a89c3a6b4c90f4b2876aeb64676e9 Mon Sep 17 00:00:00 2001 From: tqcenglish Date: Sat, 10 Aug 2019 23:51:21 +0800 Subject: [PATCH 1/3] i18n zh --- ui/src/i18next.ts | 2 + ui/src/translations/zh.ts | 161 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 ui/src/translations/zh.ts diff --git a/ui/src/i18next.ts b/ui/src/i18next.ts index 3b2ad60..0c02abf 100644 --- a/ui/src/i18next.ts +++ b/ui/src/i18next.ts @@ -2,12 +2,14 @@ import * as i18n from 'i18next'; import { getLanguage } from './utils'; import { en } from './translations/en'; import { de } from './translations/de'; +import { zh } from './translations/zh'; // https://github.com/nimbusec-oss/inferno-i18next/blob/master/tests/T.test.js#L66 // TODO don't forget to add moment locales for new languages. const resources = { en: en, de: de, + zh: zh, } function format(value: any, format: any, lng: any) { diff --git a/ui/src/translations/zh.ts b/ui/src/translations/zh.ts new file mode 100644 index 0000000..45d1db3 --- /dev/null +++ b/ui/src/translations/zh.ts @@ -0,0 +1,161 @@ +export const zh = { + translation: { + post: '帖子', + remove_post: '移除帖子', + no_posts: '没有帖子.', + create_a_post: '创建新帖子', + create_post: '创建帖子', + number_of_posts:'{{count}} 帖子', + posts: '帖子', + related_posts: '相关的帖子', + comments: '节点', + number_of_comments:'{{count}} 节点', + remove_comment: '移除节点', + communities: '节点', + create_a_community: '创建新节点', + create_community: '创建节点', + remove_community: '移除节点', + subscribed_to_communities:'订阅新 <1>节点', + trending_communities:'<1>节点趋势', + list_of_communities: '节点列表', + community_reqs: '包含小写与下划线且没有空格.', + edit: '编辑', + reply: '回应', + cancel: '取消', + unlock: '解锁', + lock: '加锁', + link: '链接', + mod: 'mod', + mods: 'mods', + moderates: 'Moderates', + remove_as_mod: 'remove as mod', + appoint_as_mod: 'appoint as mod', + modlog: 'Modlog', + admin: 'admin', + admins: 'admins', + remove_as_admin: '移除管理权限', + appoint_as_admin: '添加管理权限', + remove: '移除', + removed: '已移除', + locked: '已加锁', + reason: '原因', + mark_as_read: '标记未读', + mark_as_unread: '标记已读', + delete: '删除', + deleted: '已删除', + restore: '恢复', + ban: '禁止', + ban_from_site: '禁止此站点', + unban: '取消', + unban_from_site: '取消禁止', + save: '保存', + unsave: '取消保存', + create: '创建', + username: '用户名', + email_or_username: '邮箱或用户名', + number_of_users:'{{count}} 用户', + number_of_subscribers:'{{count}} 订阅', + number_of_points:'{{count}} 分', + name: '名字', + title: '标题', + category: '分类', + subscribers: '订阅', + both: '全部', + saved: '保存', + unsubscribe: '取消订阅', + subscribe: '订阅', + subscribed: '已订阅', + prev: '上一页', + next: '下一页', + sidebar: '侧边栏', + sort_type: '排序方式', + hot: '最热', + new: '最新', + top_day: '今日最热', + week: '周', + month: '月', + year: '年', + all: '所有', + top: '最热', + api: 'API', + inbox: '收件箱', + inbox_for: '<1>{{user}} 收件箱', + mark_all_as_read: '标记所有已读', + type: '类型', + unread: '未读', + reply_sent: '回复发送', + search: '搜索', + overview: '个人中心', + view: '查看', + logout: '注销', + login_sign_up: '登录/注册', + login: '登录', + sign_up: '注册', + notifications_error: '你的浏览器不支持桌面通知,尝试 Firefox 或 Chrome', + unread_messages: '未读消息', + password: '密码', + verify_password: '确认密码', + email: '邮箱', + optional: '选项', + expires: '过期', + url: 'URL', + body: '内容', + copy_suggested_title: '复制建议的标题: {{title}}', + community: '节点', + expand_here: '展开', + subscribe_to_communities: '订阅一些 <1>节点.', + chat: '聊天', + no_results: '没有结果.', + setup: '设置', + lemmy_instance_setup: 'Lemmy Instance Setup', + setup_admin: '设置管理员', + your_site: '你的站点', + modified: '修改', + sponsors: 'Sponsors', + sponsors_of_lemmy: 'Sponsors of Lemmy', + sponsor_message: 'Lemmy is free, <1>open-source software, meaning no advertising, monetizing, or venture capital, ever. Your donations directly support full-time development of the project. Thank you to the following people:', + support_on_patreon: 'Support on Patreon', + general_sponsors:'General Sponsors are those that pledged $10 to $39 to Lemmy.', + crypto: '加密', + bitcoin: '比特币', + ethereum: '以太币', + code: '代码', + joined: '已加入', + powered_by: '保留所有权利', + landing_0: 'Lemmy is a <1>link aggregator / reddit alternative, intended to work in the <2>fediverse.<3>Its self-hostable, has live-updating comment threads, and is tiny (<4>~80kB). Federation into the ActivityPub network is on the roadmap. <5>This is a <6>very early beta version, and a lot of features are currently broken or missing. <7>Suggest new features or report bugs <8>here.<9>Made with <10>Rust, <11>Actix, <12>Inferno, <13>Typescript.', + not_logged_in: '未登录.', + community_ban: '你被此节点禁止.', + site_ban: '你被此站点禁止', + couldnt_create_comment: '不能创建评论.', + couldnt_like_comment: '不能收藏评论.', + couldnt_update_comment: '不能更新评论.', + couldnt_save_comment: '不能保存评论.', + no_comment_edit_allowed: '不允许编辑评论.', + no_post_edit_allowed: '不运行编辑帖子.', + no_community_edit_allowed: '不允许编辑节点.', + couldnt_find_community: '不能找到节点.', + couldnt_update_community: '不能更新节点.', + community_already_exists: '节点已存在.', + community_moderator_already_exists: '节点 moderator 已存在.', + community_follower_already_exists: '节点 follower 已存在.', + community_user_already_banned: '节点用户已禁止.', + couldnt_create_post: '不能创建帖子.', + couldnt_like_post: '不能收藏帖子.', + couldnt_find_post: '不能搜寻帖子.', + couldnt_get_posts: '不能获取帖子', + couldnt_update_post: '不能更新帖子', + couldnt_save_post: '不能保持帖子.', + no_slurs: '和谐.', + not_an_admin: '不是管理员.', + site_already_exists: '站点已存在.', + couldnt_update_site: '不能更新站点.', + couldnt_find_that_username_or_email: '用户名/邮箱不存在.', + password_incorrect: '密码不正确.', + passwords_dont_match: '密码不匹配.', + admin_already_created: '抱歉,管理员已存在.', + user_already_exists: '用户已存在.', + couldnt_update_user: '不可以更新用户.', + system_err_login: '系统错误. 尝试注销再登录', + }, +} + From b18cc49d581eeb9dfb47d75f456011f92b822f5d Mon Sep 17 00:00:00 2001 From: tqcenglish Date: Sun, 11 Aug 2019 00:43:36 +0800 Subject: [PATCH 2/3] fix comment error --- ui/src/translations/zh.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/src/translations/zh.ts b/ui/src/translations/zh.ts index 45d1db3..59e09d7 100644 --- a/ui/src/translations/zh.ts +++ b/ui/src/translations/zh.ts @@ -8,9 +8,9 @@ export const zh = { number_of_posts:'{{count}} 帖子', posts: '帖子', related_posts: '相关的帖子', - comments: '节点', - number_of_comments:'{{count}} 节点', - remove_comment: '移除节点', + comments: '评论', + number_of_comments:'{{count}} 评论', + remove_comment: '移除评论', communities: '节点', create_a_community: '创建新节点', create_community: '创建节点', @@ -18,7 +18,7 @@ export const zh = { subscribed_to_communities:'订阅新 <1>节点', trending_communities:'<1>节点趋势', list_of_communities: '节点列表', - community_reqs: '包含小写与下划线且没有空格.', + community_reqs: '包含小写与下划线且没有空格的字符串.', edit: '编辑', reply: '回应', cancel: '取消', @@ -71,7 +71,7 @@ export const zh = { sort_type: '排序方式', hot: '最热', new: '最新', - top_day: '今日最热', + top_day: '今日', week: '周', month: '月', year: '年', From 98bce112a74ad47f2f07f6ee16604a4775ff24a2 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 10 Aug 2019 11:26:28 -0700 Subject: [PATCH 3/3] Fixing locales in fuse. Coercing zh to zh-cn for moment. --- ui/fuse.js | 3 +++ ui/src/components/moment-time.tsx | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ui/fuse.js b/ui/fuse.js index 4755d9f..f77effb 100644 --- a/ui/fuse.js +++ b/ui/fuse.js @@ -24,6 +24,9 @@ Sparky.task('config', _ => { transformers: { before: [transformClasscat(), transformInferno()], }, + alias: { + 'locale': 'moment/locale' + }, plugins: [ EnvPlugin({ NODE_ENV: isProduction ? 'production' : 'development' }), CSSPlugin(), diff --git a/ui/src/components/moment-time.tsx b/ui/src/components/moment-time.tsx index 021cf5f..77dcaf8 100644 --- a/ui/src/components/moment-time.tsx +++ b/ui/src/components/moment-time.tsx @@ -1,6 +1,7 @@ import { Component } from 'inferno'; import * as moment from 'moment'; -// import 'moment/locale/de.js'; +// import 'moment/locale/de'; +import 'moment/locale/zh-cn'; import { getLanguage } from '../utils'; import { i18n } from '../i18next'; @@ -16,7 +17,14 @@ export class MomentTime extends Component { constructor(props: any, context: any) { super(props, context); - moment.locale(getLanguage()); + + // Moment doesnt have zh, only zh-cn + let lang = getLanguage(); + if (lang == 'zh') { + lang = 'zh-cn'; + } + + moment.locale(lang); } render() {