说明:Gitlab本身是英文环境的,虽然在用户设置的首选语言内可以配置成中文,但也只是少部分是中文的,大部分还是英文环境;所以对于要求不严格的情况下对Gitlab进行汉化也是不错的选择,特别是汉化后大部分都是中文的,只是少部分还是英文的;对于全部英文环境来说已经不错了。
1、查看本地Gitlab版本:rpm -qa gitlab-ce
[root@izuf6fy69k7l7e20jogcj7z ~]# rpm -qa gitlab-ce gitlab-ce-11.1.4-ce.0.el7.x86_64
2、下载Gitlab汉化版本库:git clone https://gitlab.com/xhang/gitlab.git
[root@izuf6fy69k7l7e20jogcj7z ~]# pwd /root [root@izuf6fy69k7l7e20jogcj7z ~]# git clone https://gitlab.com/xhang/gitlab.git Cloning into 'gitlab'... remote: Enumerating objects: 818293, done. remote: Counting objects: 100% (818293/818293), done. remote: Compressing objects: 100% (173737/173737), done. remote: Total 818293 (delta 638367), reused 814629 (delta 634763) Receiving objects: 100% (818293/818293), 317.67 MiB | 6.22 MiB/s, done. Resolving deltas: 100% (638367/638367), done.
3、查看确认该汉化包版本:cat gitlab/VERSION
[root@izuf6fy69k7l7e20jogcj7z ~]# cat gitlab/VERSION 11.1.6
查看下来发现这个版本是11.1.6的,要高于汉化的11.1.4版本;不要急,汉化包的版本是包含的关系,就是高版本包含低版本的(11.1.6包含11.1.4的),后面制作补丁时只要指定版本号即可。
4、停止Gitlab服务:gitlab-ctl stop
[root@izuf6fy69k7l7e20jogcj7z ~]# gitlab-ctl stop ok: down: alertmanager: 0s, normally up ok: down: crond: 1s, normally up ok: down: gitaly: 0s, normally up ok: down: gitlab-monitor: 0s, normally up ok: down: gitlab-workhorse: 0s, normally up ok: down: logrotate: 0s, normally up ok: down: nginx: 1s, normally up ok: down: node-exporter: 0s, normally up ok: down: postgres-exporter: 1s, normally up ok: down: postgresql: 0s, normally up ok: down: prometheus: 0s, normally up ok: down: redis: 0s, normally up ok: down: redis-exporter: 0s, normally up ok: down: sidekiq: 0s, normally up ok: down: unicorn: 0s, normally up
5、进入Gitlab汉化目录:cd gitlab/
[root@izuf6fy69k7l7e20jogcj7z ~]# cd gitlab [root@izuf6fy69k7l7e20jogcj7z gitlab]#
6、指定版本比较汉化标签和原标签并导出patch用的diff文件到/root下:git diff v11.1.4 v11.1.4-zh > ../11.1.4-zh.diff
[root@izuf6fy69k7l7e20jogcj7z gitlab]# git diff v11.1.4 v11.1.4-zh > ../11.1.4-zh.diff [root@izuf6fy69k7l7e20jogcj7z gitlab]# ll ../ total 432212 -rw-r--r-- 1 root root 1154534 Aug 31 17:40 11.1.4-zh.diff drwxr-xr-x 28 root root 4096 Aug 31 17:31 gitlab -rw-r--r-- 1 root root 441423852 Aug 1 05:41 gitlab-ce-11.1.4-ce.0.el7.x86_64.rpm
7、将刚刚导出的diff文件作为补丁更新到本地Gitlab中:patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < ../11.1.4-zh.diff #一路回车到底
[root@izuf6fy69k7l7e20jogcj7z gitlab]# patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < ../11.1.4-zh.diff can't find file to patch at input line 5 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |diff --git a/app/assets/javascripts/awards_handler.js b/app/assets/javascripts/awards_handler.js |index 70f20c5..b8089dd 100644 |--- a/app/assets/javascripts/awards_handler.js |+++ b/app/assets/javascripts/awards_handler.js -------------------------- File to patch: Skip this patch? [y] Skipping patch. 4 out of 4 hunks ignored can't find file to patch at input line 48 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |diff --git a/app/assets/javascripts/behaviors/quick_submit.js b/app/assets/javascripts/behaviors/quick_submit.js |index b6e2781..b17719e 100644 |--- a/app/assets/javascripts/behaviors/quick_submit.js |+++ b/app/assets/javascripts/behaviors/quick_submit.js -------------------------- File to patch: Skip this patch? [y] ......此处省略...... Skipping patch. 2 out of 2 hunks ignored can't find file to patch at input line 1165 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |diff --git a/app/assets/stylesheets/pages/ui_dev_kit.scss b/app/assets/stylesheets/pages/ui_dev_kit.scss |index 48ac5b2..e1375b8 100644 |--- a/app/assets/stylesheets/pages/ui_dev_kit.scss |+++ b/app/assets/stylesheets/pages/ui_dev_kit.scss -------------------------- File to patch: Skip this patch? [y] Skipping patch. 1 out of 1 hunk ignored patching file app/controllers/abuse_reports_controller.rb patching file app/controllers/admin/appearances_controller.rb ......此处省略...... patching file public/503.html patching file public/deploy.html
8、启动Gitlab服务:gitlab-ctl start
[root@izuf6fy69k7l7e20jogcj7z gitlab]# gitlab-ctl start ok: run: alertmanager: (pid 3389) 0s ok: run: crond: (pid 3397) 1s ok: run: gitaly: (pid 3404) 0s ok: run: gitlab-monitor: (pid 3409) 1s ok: run: gitlab-workhorse: (pid 3415) 0s ok: run: logrotate: (pid 3425) 1s ok: run: nginx: (pid 3440) 0s ok: run: node-exporter: (pid 3447) 0s ok: run: postgres-exporter: (pid 3451) 0s ok: run: postgresql: (pid 3456) 0s ok: run: prometheus: (pid 3464) 1s ok: run: redis: (pid 3471) 0s ok: run: redis-exporter: (pid 3477) 1s ok: run: sidekiq: (pid 3556) 0s ok: run: unicorn: (pid 3563) 1s
9、此时汉化操作已完成(以防万一有误可以执行重新配置命令:gitlab-ctl reconfigure);Gitlab服务刚启动会有访问页面502错误,稍等下刷新下即可。
10、用户端配置:用户登录后点击右上角的头像>>选择“Settings”>>语言偏好配置“简体中文”后点击下面的“更新个人资料”按钮保存即可。