fix: 修复国际化文案问题

并优化代码
pull/70/head
moonrailgun 2 years ago
parent 2ed79fb5dd
commit e56eda0387

File diff suppressed because it is too large Load Diff

@ -4,6 +4,7 @@ import {
fetchUtils,
ShowGuesser,
CustomRoutes,
TranslationMessages,
} from 'react-admin';
import jsonServerProvider from 'ra-data-json-server';
import { authProvider, authStorageKey } from './authProvider';
@ -21,10 +22,7 @@ import { Dashboard } from './dashboard';
import { Route } from 'react-router-dom';
import { TailchatNetwork } from './network';
import { TailchatLayout } from './layout';
import polyglotI18nProvider from 'ra-i18n-polyglot';
import chineseMessages from 'ra-language-chinese';
const i18nProvider = polyglotI18nProvider(() => chineseMessages, 'ch');
import { i18nProvider } from './i18n';
const httpClient: typeof fetchUtils.fetchJson = (url, options = {}) => {
try {
@ -57,8 +55,8 @@ export const App = () => (
disableTelemetry={true}
authProvider={authProvider}
dataProvider={dataProvider}
requireAuth={true}
i18nProvider={i18nProvider}
requireAuth={true}
>
<Resource
icon={PersonIcon}

@ -0,0 +1,179 @@
import { TranslationMessages } from 'react-admin';
import _merge from 'lodash/merge';
import englishMessages from 'ra-language-english';
import polyglotI18nProvider from 'ra-i18n-polyglot';
export { englishMessages };
const chineseMessages: TranslationMessages = _merge(englishMessages, {
ra: {
action: {
add_filter: '增加检索',
add: '增加',
back: '回退',
bulk_actions: '选中%{smart_count}项',
cancel: '取消',
clear_input_value: '清空输入',
clone: '克隆',
confirm: '确认',
create: '新建',
create_item: '新建 %{item}',
delete: '删除',
edit: '编辑',
export: '导出',
list: '列表',
refresh: '刷新',
remove_filter: '移除检索',
remove: '删除',
save: '保存',
search: '检索',
select_all: '选中全部',
select_row: '选中这行',
show: '查看',
sort: '排序',
undo: '撤销',
unselect: '反选',
expand: '展开',
close: '关闭',
open_menu: '打开菜单',
close_menu: '关闭菜单',
update: '更新',
move_up: '上移',
move_down: '下移',
open: '打开',
toggle_theme: '切换主题',
},
boolean: {
true: '是',
false: '否',
null: '',
},
page: {
create: '新建 %{name}',
dashboard: '概览',
edit: '%{name} #%{id}',
error: '出现错误',
list: '%{name} 列表',
loading: '加载中',
not_found: '未发现',
show: '%{name} #%{id}',
empty: '无 %{name} ',
invite: '要增加吗?',
},
input: {
file: {
upload_several: '将文件集合拖拽到这里, 或点击这里选择文件集合.',
upload_single: '将文件拖拽到这里, 或点击这里选择文件.',
},
image: {
upload_several: '将图片文件集合拖拽到这里, 或点击这里选择图片文件集合.',
upload_single: '将图片文件拖拽到这里, 或点击这里选择图片文件.',
},
references: {
all_missing: '未找到参考数据.',
many_missing: '至少有一条参考数据不再可用.',
single_missing: '关联的参考数据不再可用.',
},
password: {
toggle_visible: '隐藏密码',
toggle_hidden: '显示密码',
},
},
message: {
about: '关于',
are_you_sure: '您确定操作?',
bulk_delete_title: '删除 %{name} |||| 删除 %{smart_count}项 %{name} ',
bulk_delete_content:
'您确定要删除 %{name}? |||| 您确定要删除 %{smart_count} 项?',
bulk_update_content:
'你确定要更新 %{name}? |||| 你确定想更新 %{smart_count} 项?',
bulk_update_title: '更新 %{name} |||| 您确定更新 %{smart_count} %{name}',
delete_content: '您确定要删除该条目?',
delete_title: '删除 %{name} #%{id}',
details: '详情',
error: '客户端错误导致请求未完成.',
invalid_form: '表单输入无效. 请检查错误提示',
loading: '正在加载页面, 请稍候',
no: '否',
not_found: '您输入了错误的URL或者错误的链接.',
yes: '是',
unsaved_changes: '修改未保存. 放弃修改吗?',
},
navigation: {
no_results: '结果为空',
no_more_results: '页码 %{page} 超出边界. 试试上一页.',
page_out_of_boundaries: '页码 %{page} 超出边界',
page_out_from_end: '已到最末页',
page_out_from_begin: '已到最前页',
page_range_info: '%{offsetBegin}-%{offsetEnd} / %{total}',
partial_page_range_info:
'%{offsetBegin}-%{offsetEnd} of more than %{offsetEnd}',
current_page: '页码 %{page}',
page: '跳转到 %{page}',
prev: '向前',
first: '第一页',
last: '最后一页',
next: '向后',
previous: '先前第一页',
page_rows_per_page: '每页行数:',
skip_nav: '跳到内容',
},
sort: {
sort_by: '按 %{field} %{order}',
ASC: '升序',
DESC: '降序',
},
auth: {
auth_check_error: '请登录以继续',
user_menu: '设置',
username: '用户名',
password: '密码',
sign_in: '登录',
sign_in_error: '验证失败, 请重试',
logout: '退出',
},
notification: {
updated: '条目已更新 |||| %{smart_count} 项条目已更新',
created: '条目已新建',
deleted: '条目已删除 |||| %{smart_count} 项条目已删除',
bad_item: '不正确的条目',
item_doesnt_exist: '条目不存在',
http_error: '与服务通信出错',
canceled: '取消动作',
data_provider_error: 'dataProvider错误. 请检查console的详细信息.',
i18n_error: '无法加载指定语言包',
logged_out: '会话失效, 请重连.',
not_authorized: '您无权访问此资源.',
},
validation: {
required: '必填',
minLength: '必须不少于 %{min} 个字符',
maxLength: '必须不多于 %{max} 个字符',
minValue: '必须不小于 %{min}',
maxValue: '必须不大于 %{max}',
number: '必须为数字',
email: '必须是有效的邮箱',
oneOf: '必须为: %{options}其中一项',
regex: '必须符合指定的格式 (regexp): %{pattern}',
},
saved_queries: {
label: '保存查询',
query_name: '搜索名称',
new_label: '保存当前的查询...',
new_dialog_title: '将当前查询另存为',
remove_label: '删除保存的查询',
remove_label_with_name: '删除查询 "%{name}"',
remove_dialog_title: '是否删除保存的查询?',
remove_message: '确实要从保存的查询列表中删除该项吗?',
help: '筛选列表并保存此查询以备将来使用',
},
},
});
export const i18nProvider = polyglotI18nProvider((locale: string) => {
if (locale === 'ch') {
return chineseMessages;
} else {
return englishMessages;
}
}, 'ch');

@ -30,11 +30,11 @@
"lodash": "^4.17.21",
"md5": "^2.3.0",
"morgan": "^1.10.0",
"ra-data-json-server": "^4.6.3",
"ra-data-json-server": "^4.7.0",
"ra-i18n-polyglot": "^4.7.0",
"ra-language-chinese": "^2.0.10",
"ra-language-english": "^4.7.0",
"react": "^18.2.0",
"react-admin": "^4.6.3",
"react-admin": "^4.7.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.5.0",
"tailchat-server-sdk": "workspace:^0.0.14",

Loading…
Cancel
Save