langMap.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. const lang = {
  2. cn:'zh-cn',
  3. en:'en-us',
  4. }
  5. const textArr = [
  6. {
  7. keys: ["首页"],
  8. "en-us": 'Index'
  9. },
  10. {
  11. keys: ["English"],
  12. "en-us": '中文'
  13. },
  14. {
  15. keys: ["合方圆管理平台","管理平台"],
  16. "en-us": 'HFY management platform',
  17. "abbr-en-us": 'HFY DMP'
  18. },
  19. {
  20. keys: ["智慧能源"],
  21. "en-us": 'Smart Energy (SE)',
  22. "abbr-en-us": 'S Energy'
  23. },
  24. {
  25. keys: ["输电线路摄像头"],
  26. "en-us": 'Power Transmission Line Camera',
  27. "abbr-en-us": 'TCLC ',
  28. },
  29. {
  30. keys: ["4G低功耗摄像头"],
  31. "en-us": '4G Low Power Camera',
  32. "abbr-en-us": '4G-LP Camera'
  33. },
  34. {
  35. keys: ["自动变焦双目协同摄像头"],
  36. "en-us": 'Auto-focus Dual-lens Coordinated Camera',
  37. "abbr-en-us": 'AF dual-camera'
  38. },
  39. {
  40. keys: ["M2M产品"],
  41. "en-us": 'M2M Products',
  42. },
  43. {
  44. keys: ["智能终端"],
  45. "en-us": 'Intelligent Terminal',
  46. },
  47. {
  48. keys: ["关于我们"],
  49. "en-us": 'About us',
  50. },
  51. {
  52. keys: ["智能产品"],
  53. "en-us": 'smart product',
  54. },
  55. {
  56. keys: ["服务与支持"],
  57. "en-us": 'Server & Support',
  58. },
  59. {
  60. keys: ["快速链接"],
  61. "en-us": 'Quick link',
  62. },
  63. {
  64. keys: ["选择语言"],
  65. "en-us": 'Languages',
  66. },
  67. {
  68. keys: ["联系我们"],
  69. "en-us": 'Contact Us',
  70. },
  71. {
  72. keys: ["产品中心"],
  73. "en-us": 'ProductCenter',
  74. },
  75. {
  76. keys: ["了解更多"],
  77. "en-us": 'More',
  78. },
  79. {
  80. keys: ["持续创新的软硬件产品","持续创新"],
  81. "en-us": 'Sustainable Innovation',
  82. },
  83. {
  84. keys: ["输入产品名称","请输入"],
  85. "en-us": 'input key for search',
  86. },
  87. {
  88. keys: ["产品类别"],
  89. "en-us": 'Product Type',
  90. },
  91. {
  92. keys: ["解决方案"],
  93. "en-us": 'Solution',
  94. },
  95. {
  96. keys: ["新闻中心"],
  97. "en-us": 'News',
  98. },
  99. ]
  100. const i18Paths =
  101. [
  102. {
  103. keys: ['/','/index'],
  104. "en-us": '/index_en',
  105. }
  106. ]
  107. function getText(langType,langKey){
  108. let item = textArr.find(val=>val.keys.includes(langKey));
  109. if(item && item[langType]){
  110. return item[langType]
  111. }else{
  112. return langKey
  113. }
  114. }
  115. function getAbbrText(langType,langKey){
  116. let item = textArr.find(val=>val.keys.includes(langKey));
  117. let AbbrTypeKey = "abbr-"+langType
  118. if(item){
  119. if(item[AbbrTypeKey]){
  120. return item[AbbrTypeKey]
  121. }else if(item && item[langType]){
  122. return item[langType]
  123. }
  124. }
  125. return langKey
  126. }
  127. function getLangPathStr(langType,langKey){
  128. let item = i18Paths.find(val=>val.keys.includes(langKey));
  129. if(item && item[langType]){
  130. return item[langType]
  131. }else{
  132. return langKey
  133. }
  134. }
  135. export default {
  136. lang,
  137. getText,
  138. getAbbrText,
  139. getLangPathStr
  140. }