【问题标题】:How to translate the menu navbar in core ui react?如何翻译核心ui中的菜单导航栏反应?
【发布时间】:2020-02-15 14:19:47
【问题描述】:

我正在使用react : coreui 的管理模板。为了翻译组件中的标签,我使用 react-intl。

我想翻译导航栏,它是一个简单的数组:

    export default {
  items: [
    {
        title: true,
        name: 'ESSAI DOM',
    },
    {
        name: 'Schools',
        url: '/schools',
        icon: 'fa fa-university'
    },
.... other items...
  ],  
};

我的翻译是在这样的 json 中(例如“法语”):

{
    "Schools.Schools.title": "Ecoles"
}

在这个例子中,我想写这样的东西:

    {
     name : some_function(languageId, 'Schools.Schools.title'),
     .....
}

我该怎么做?

【问题讨论】:

    标签: reactjs react-intl core-ui


    【解决方案1】:

    我找到了这样的解决方案:

        export default {
      items: [
        {
            name : <FormattedMessage id="Navigation.home" defaultMessage="Home" />,
            url: '/',
            icon: 'fa fa-home'
        },
        {
            name : <FormattedMessage id="Navigation.schools" defaultMessage="Schools" />,
            url: '/schools',
            icon: 'fa fa-university'
        },
      ],  
    };
    

    我不知道我们可以在类之外操作 React 组件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-30
      • 1970-01-01
      • 2021-04-29
      • 2021-12-06
      • 2013-05-10
      • 2022-11-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多