Ghost博客完整汉化

既然是用中文写作,有时候还是觉得网站能尽量汉化就汉化吧。

幸好在Ghost博客上实现汉化并不难。

首先我们在后台管理General页面中将网站语言设为zh-CN,如图:

然后我们修改Nubia主题的locale文件。

cd /var/www/ghost/content/themes/nubia/locales
sudo cp en.json zh-CN.json
sudo nano zh-CN.json

根据个人喜好对英文进行翻译,以下列出我的文件内容:

{
  "More Posts": "更多内容",
  "Loading": "正在载入",
  "Page Not Found": "无法找到页面",
  "Recent Posts": "近期更新",
  "Home Page": "主页",
  "Back": "返回",
  "Subscribe": "Subscribe",
  "Subscribe to {blogtitle}": "Subscribe to {blogtitle}",
  "Subscribed!": "Subscribed!",
  "with the email address": "with the email address",
  "Email": "邮件",
  "Your email address": "你的邮件地址",
  "You've successfully subscribed to": "You've successfully subscribed to",
  "Featured Post": "加星内容",
  "Share on Twitter": "分享至Twitter",
  "Share on Facebook": "分享至Facebook",
  "Share on LinkedIn": "分享至LinkedIn",
  "Share on Pinterest": "分享至Pinterest",
  "Share via Email": "分享至邮件",
  "Copy link": "拷贝链接",
  "Link copied to clipboard": "链接已被拷贝至剪贴板",
  "Search": "搜索",
  "Search {blogtitle}": "搜索 {blogtitle}",
  "Type to Search": "请输入搜索内容",
  "Navigation": "导航",
  "Newsletter": "Newsletter",
  "Published with {ghostlink}": "使用{ghostlink}发布/ ",
  "You Might Be Interested In": "你可能感兴趣的内容",
  "Tags": "热门标签",
  "Advertise": "广告",
  "Comments": "评论(需翻墙)",
  "1 min read": "1 分钟读完",
  "% min read": "约 % 分钟读完"
}

这就结束了吗?

不没有。

时间显示虽然改为中文,但是是别扭的按美国格式倒序显示的,如双十一会显示为11.11月.2018,看着好别扭。
幸好这也难不倒我们。

sudo nano /var/www/ghost/current/core/server/helpers/date.js

format = options.hash.format || 'MMM DD, YYYY';

修改为如下所示:

format = 'YYYY, MMM Do';

注:格式标准参考下述链接:
https://momentjs.com/docs/
由于此文件会随Ghost版本更新而重置,请更新后再次手动修改之。

最后别忘记修复文件权限并重启后生效。

cd /var/www/ghost
sudo chown -R ghost:ghost ./content
ghost restart

一步步教你从零开始搭博客系列: