首页 > 解决方案 > 如何使用 Hugo 和 NetlifyCMS 管理国际化

问题描述

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

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

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

标签: internationalizationtranslationhugonetlifynetlify-cms

解决方案


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

  - 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}

推荐阅读