前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >GitLab 14 修改默认语言

GitLab 14 修改默认语言

原创
作者头像
Breeze.
发布2023-02-16 22:47:39
1.7K0
发布2023-02-16 22:47:39
举报

GitLab 安装成功后默认是英语,只有登录后才能手动指定为中文,想要修改默认语言还是相对麻烦的,方法如下:

第一步

打开/opt/gitlab/embedded/service/gitlab-rails/config/application.rb 文件,搜索config.i18n.default_locale = : 去掉文件前面的注释,然后把后面的值改成zh_CN ,保存文件。

第二步

进入/opt/gitlab/embedded/service/gitlab-rails/config/locales/目录,建立zh_CN.yml文件,内容如下:

复制

# Sample localization file for English. Add more files in this directory for other locales.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
  hello: "你好,世界"
  activerecord:
    attributes:
      issue_link:
        source: 问题来源
        target: 问题目标
      group:
        path: 群组 URL
      member:
        user: "成员的邮箱地址"
        invite_email: "成员的邮箱地址"
      project/error_tracking_setting:
        token: "Auth 令牌"
        project: "项目"
        api_url: "Sentry API URL"
      project/metrics_setting:
        external_dashboard_url: "外部仪表板 URL"
      project/grafana_integration:
        token: "Grafana HTTP API 令牌"
        grafana_url: "Grafana API URL"
        grafana_enabled: "启用 Grafana 集成"
      service_desk_setting:
        project_key: "项目名称后缀"
      user/user_detail:
        job_title: '工作标题'
      user/user_detail:
        bio: 'Bio'
  views:
    pagination:
      previous: "上"
      next: "下"
  date:
    abbr_day_names:
    - 日
    - 一
    - 二
    - 三
    - 四
    - 五
    - 六
    abbr_month_names:
    -
    - 1月
    - 2月
    - 3月
    - 4月
    - 5月
    - 6月
    - 7月
    - 8月
    - 9月
    - 10月
    - 11月
    - 12月
    day_names:
    - 星期天
    - 星期一
    - 星期二
    - 星期三
    - 星期四
    - 星期五
    - 星期六
    formats:
      default: "%Y-%m-%d"
      long: "%B %d, %Y"
      short: "%b %d"
      admin: "%e %b, %Y"
    month_names:
    -
    - 一月
    - 二月
    - 三月
    - 四月
    - 五月
    - 六月
    - 七月
    - 八月
    - 九月
    - 十月
    - 十一月
    - 十二月
    order:
    - :year
    - :month
    - :day
  datetime:
    time_ago_in_words:
      half_a_minute: "半分钟以前"
      less_than_x_seconds:
        one:   "不到 1 秒前"
        other: "不到 %{count} 秒前"
      x_seconds:
        one:   "1 秒前"
        other: "%{count} 秒前"
      less_than_x_minutes:
        one:   "不到 1 分钟前"
        other: "不到 %{count} 分钟前"
      x_minutes:
        one:   "1 分钟前"
        other: "%{count} 分钟前"
      about_x_hours:
        one:   "大约 1 小时前"
        other: "大约 %{count} 小时前"
      x_days:
        one:   "1 天前"
        other: "%{count} 天前"
      about_x_months:
        one:   "大约 1 个月前"
        other: "大约 %{count} 个月前"
      x_months:
        one:   "1 个月前"
        other: "%{count} 个月前"
      about_x_years:
        one:   "大约 1 年前"
        other: "大约 %{count} 年前"
      over_x_years:
        one:   "1 年多以前"
        other: "超过 %{count} 年以前"
      almost_x_years:
        one:   "大约 1 年前"
        other: "大约 %{count} 年前"
    distance_in_words:
      about_x_hours:
        one: 大约 1 小时
        other: 大约 %{count} 小时
      about_x_months:
        one: 大约 1 个月
        other: 大约 %{count} 个月
      about_x_years:
        one: 大约 1 年
        other: 大约 %{count} 年
      almost_x_years:
        one: 将近 1 年
        other: 将近 %{count} 年
      half_a_minute: 半分钟
      less_than_x_minutes:
        one: 不到一分钟
        other: 不到 %{count} 分钟
      less_than_x_seconds:
        one: 不到 1 秒
        other: 不到 %{count} 秒
      over_x_years:
        one: 1 年多以前
        other: 超过 %{count} 年
      x_days:
        one: 1 天
        other: "%{count} 天"
      x_minutes:
        one: 1 分钟
        other: "%{count} 分钟"
      x_months:
        one: 1 月
        other: "%{count} 月"
      x_years:
        one: 1 年
        other: "%{count} 年"
      x_seconds:
        one: 1 秒
        other: "%{count} 秒"
    prompts:
      day: 日
      hour: 小时
      minute: 分钟
      month: 月
      second: 秒
      year: 年
  errors:
    format: "%{attribute} %{message}"
    messages:
      label_already_exists_at_group_level: "%{group} 的组级别已存在。 请选择另一个。"
      username_exists_as_a_different_namespace: 具有该用户名的用户、别名或组已存在。
      wrong_size: "大小错误(应为 %{file_size})"
      size_too_small: "太小(至少应为 %{file_size})"
      size_too_big: "太大(最多应为 %{file_size})"
      accepted: 必须接受
      blank: 不能为空
      present: 必须为空
      confirmation: 不匹配 %{attribute}
      empty: 不能为空
      equal_to: 必须等于 %{count}
      even: 必须相等
      exclusion: 被预定了
      greater_than: 必须大于 %{count}
      greater_than_or_equal_to: 必须大于或等于 %{count}
      inclusion: 不包含在列表中
      invalid: 是无效的
      less_than: 必须小于 %{count}
      less_than_or_equal_to: 必须小于或等于 %{count}
      model_invalid: "Validation failed: %{errors}"
      not_a_number: 不是数字
      not_an_integer: 必须是整数
      odd: 一定是奇数
      required: 必须存在
      taken: 已经被使用了
      too_long:
        one: 太长(最多 1 个字符)
        other: 太长(最多 %{count} 个字符)
      too_short:
        one: 太短(最少 1 个字符)
        other: 太短(最少 %{count} 个字符)
      wrong_length:
        one: 长度错误(应该是 1 个字符)
        other: 长度错误(应该是 %{count} 个字符)
      search_chars_too_long: 搜索查询太长(最多 %{count} 个字符)
      search_terms_too_long: 搜索查询太长(最多 %{count} 个字词)
      other_than: 必须不是 %{count}
    template:
      body: '以下字段存在问题:'
      header:
        one: 1 个错误禁止保存此 %{model}
        other: "%{count} 个错误禁止保存此 %{model}"
  helpers:
    select:
      prompt: 请选择
    submit:
      create: 创建 %{model}
      submit: 保存 %{model}
      update: 更新 %{model}
  number:
    currency:
      format:
        delimiter: ","
        format: "%u%n"
        precision: 2
        separator: "."
        significant: false
        strip_insignificant_zeros: false
        unit: "$"
    format:
      delimiter: ","
      precision: 3
      separator: "."
      significant: false
      strip_insignificant_zeros: false
    human:
      decimal_units:
        format: "%n %u"
        units:
          billion: 十亿
          million: 百万
          quadrillion: 千万亿
          thousand: 千
          trillion: 万亿
          unit: ''
      format:
        delimiter: ''
        precision: 3
        significant: true
        strip_insignificant_zeros: true
      storage_units:
        format: "%n %u"
        units:
          byte:
            one: Byte
            other: Bytes
          gb: GB
          kb: KB
          mb: MB
          tb: TB
    percentage:
      format:
        delimiter: ''
        format: "%n%"
    precision:
      format:
        delimiter: ''
  support:
    array:
      last_word_connector: ",和"
      two_words_connector: " 和 "
      words_connector: ","
  time:
    am: am
    formats:
      default: "%a, %d %b %Y %H:%M:%S %z"
      long: "%B %d, %Y %H:%M"
      short: "%d %b %H:%M"
      timeago_tooltip: "%b %-d, %Y %-l:%M%P"
      with_timezone: "%Y-%m-%d %H:%M:%S %z"
    pm: pm

注意此文件是基于en.yml翻译而来,翻译时的GitLab版本是14.7.1,如果版本不一致,请注意检查文件内容。

第三步

运行gitlab-ctl reconfiguregitlab-ctl restart 重新配置并重启 GitLab,就大功告成了。(宝塔面板重新配置可能会报错,请参考我的另一篇文章解决)

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 第一步
  • 第二步
  • 第三步
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档