Commit 8e5eba85f1901354180c6ccfc730ceb51669a6f4

Authored by Min
1 parent d7bd6201

1.下拉表格增加中英文翻译

src/components/Common/CommonComponent/index.js
... ... @@ -739,11 +739,24 @@ export default class CommonComponent extends Component {
739 739 /* 返回值 */
740 740 return obj;
741 741 };
742   -
  742 + getLocalizedString = (jsonStr, language) => {
  743 + try {
  744 + const data = JSON.parse(jsonStr);
  745 + return data[language] || '';
  746 + } catch (e) {
  747 + console.error('Error parsing JSON:', e);
  748 + return '';
  749 + }
  750 + };
743 751 getSelectTableOption = () => {
744 752 const { selectTableData } = this.state;
745   - const { showConfig } = this.props;
746   - const { sTableTitleSql } = showConfig;
  753 + const { showConfig, app } = this.props;
  754 + const { userinfo } = app;
  755 + let { sTableTitleSql } = showConfig;
  756 + /* 根据用户配置语言 设置表格标题 */
  757 + if (commonUtils.isJSON(sTableTitleSql) && sTableTitleSql.includes('Chinese')) {
  758 + sTableTitleSql = this.getLocalizedString(sTableTitleSql, userinfo.sLanguage);
  759 + }
747 760 const tempColumnArr = sTableTitleSql.split(',');
748 761 let scrollX = 0;
749 762 const columns = tempColumnArr.map((item, index) => {
... ...