Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can locale accept both string and object types? Because I want to add options that are not provided in translation, such as Chinese #284

Open
Heather-Li opened this issue Jun 23, 2020 · 0 comments

Comments

@Heather-Li
Copy link

Can 'locale' accept both 'string' and 'object' types? Because I want to add options that are not provided in translation, such as Chinese。
I think the function 'getMessage' can be modified as follows

  // const translationExists = (translations[locale] && translations[locale][key]);
  // const translation = translationExists ? translations[locale][key] : translations['en'][key];
 let translationExists;
  let translation;
  if (locale && typeof locale === 'object') {
    translation = locale[key] ? locale[key] : translations['en'][key];
  } else {
    translationExists = translations[locale] && translations[locale][key];
    translation = translationExists ? translations[locale][key] : translations['en'][key];
  }

And I want to provide a Chinese translation,maybe someone needs

const cn = {
  uploading: '上传中',
  uploadingItem: '上传一个项目中',
  uploadingItems: '上传 {quantity} 个项目中',
  upload: '上传',
  remove: '删除',
  download: '下载',
  rename: '重命名',
  creating: '新建中',
  creatingName: '新建 {name}中...',
  create: '新建',
  createFolder: '新建文件夹',
  zipping: '压缩中',
  zippingItem: '压缩一个项目中',
  zippingItems: '压缩 {quantity} 个项目中',
  items: 'items',
  item: 'item',
  cancel: '取消',
  confirm: '确定',
  folderName: '文件夹名称',
  files: '文件',
  fileExist: '文件或者文件夹名称 {name} 已存在',
  newName: '新名称',
  emptyName: '名称不能为空',
  tooLongFolderName: '文件夹名称不能超过25个字符',
  folderNameNotAllowedCharacters: '文件夹名称存在不被允许的字符',
  title: '名称',
  fileSize: '大小',
  lastModified: '修改日期',
  reallyRemove: '{files} 将被删除. 确定继续?',
  unableReadDir: '无法读取目录.'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant