【问题标题】:How to manage internationalization with Hugo and NetlifyCMS如何使用 Hugo 和 NetlifyCMS 管理国际化
【发布时间】:2018-08-30 11:09:25
【问题描述】:

我正在开发一个带有 NetlifyCMS 集成的 Hugo 网站(GitLab 作为后端)。 我想知道我有哪些选项可以允许从 NetlifyCMS 管理面板中修改 Hugo 使用的国际化文件(i18n/en.yaml、i18n/fr.yaml、...)。

只需为每个页面创建一个单独的集合并将一个页面的每个语言版本添加到同一集合下,即可轻松修改内容文件的翻译(_index.md、_index.fr.md、...)。

我应该如何处理 i18n 文件与 NetlifyCMS 的集成? https://gohugo.io/content-management/multilingual/#translation-of-strings

【问题讨论】:

    标签: internationalization translation hugo netlify netlify-cms


    【解决方案1】:

    在您的config.yml 中为i18n 文件创建一个File Collection,其中每种语言都有一个文件。

      - name: Language
        label: language
        delete: false
        files:
          - name: english
            file: 'i18n/en.yaml'
            label: English
            fields:
              - widget: object
                name: home
                label: Home
                fields:
                  - {widget: string, name: other, label: Other, required: true}
              - widget: object
                name: title
                label: 'Site Title'
                fields:
                  - {widget: string, name: other, label: Other, required: true}
          - name: french
            file: 'i18n/fr.yaml'
            label: French
            fields:
              - widget: object
                name: home
                label: Home
                fields:
                  - {widget: string, name: other, label: Other, required: true}
              - widget: object
                name: title
                label: 'Site Title'
                fields:
                  - {widget: string, name: other, label: Other, required: true}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-22
      • 1970-01-01
      • 1970-01-01
      • 2011-03-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多