Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

[Configuration] Multi Language Suppport #122

Open
wanzixin opened this issue Jul 18, 2021 · 8 comments
Open

[Configuration] Multi Language Suppport #122

wanzixin opened this issue Jul 18, 2021 · 8 comments
Labels
discussion Any questions about this theme.

Comments

@wanzixin
Copy link

Hi, there. I add another language in my site like this. I just want to translate the menu bar and the time, number of words and reading time of each article, not the article itself. What should I do next?
image

@ppoffice
Copy link
Owner

@wanzixin You can try to copy your article to the target language directory. For instance, just copy everything from source/_posts/*.md to source/_posts/zh-CN/.

@ppoffice ppoffice added the discussion Any questions about this theme. label Jul 18, 2021
@wanzixin
Copy link
Author

@ppoffice I did what you said, but I didn't succeed. What else should I pay attention to? This picture is my directory structure.

image

@ppoffice
Copy link
Owner

Create a test.md under both _posts and _posts/zh-CN and see if it works for that post. @wanzixin

@wanzixin
Copy link
Author

@ppoffice I create a test.md in _post, then copy it to _posts/zh-cn. When I switch to simplified Chinese, the browser displays Cannot GET /zh-cn/Diary/test/. But I do have a test.md in _post/zh-cn.

@ppoffice
Copy link
Owner

@wanzixin Try to change your permalink to :slug/:

https://github.com/ppoffice/hexo-theme-minos/blob/site/_config.yml#L19

@wanzixin
Copy link
Author

@ppoffice I change it as you said, but still get a mistake. After using the commands hexo c, hexo g and hexo s, I opened localhost:4000 and switched to simplified Chinese and got the following prompt on the console.

INFO  Start processing
INFO  Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.
Unhandled rejection Error: /Users/wanzixin/study/MyBlog/themes/minos/layout/post.ejs:3
    1| <section class="section">
    2|     <div class="container">
 >> 3|     <%- partial('common/article', { post: page, index: false }) %>
    4|     </div>
    5| </section>

/Users/wanzixin/study/MyBlog/themes/minos/layout/common/article.ejs:11
    9|     <div class="article-meta columns is-variable is-1 is-multiline is-mobile is-size-7-mobile">
    10|         <span class="column is-narrow">
 >> 11|             <% if (has_config('article.date_format') && get_config('article.date_format') === 'relative' ) { %>
    12|                 <time datetime="<%= date_xml(post.date) %>" itemprop="datePublished"><%= format_date_full(post.date) %></time>
    13|             <% } else if (has_config('article.date_format') && get_config('article.date_format') === 'full' ) { %>
    14|                 <span><%= format_date_full(post.date) %></span>

Function yaml.safeLoad is removed in js-yaml 4. Use yaml.load instead, which is now safe by default.
    at Object.safeLoad (/Users/wanzixin/study/MyBlog/node_modules/js-yaml/index.js:10:11)
    at getThemeConfig (/Users/wanzixin/study/MyBlog/themes/minos/scripts/99_config.js:33:37)
    at Object.<anonymous> (/Users/wanzixin/study/MyBlog/themes/minos/scripts/99_config.js:49:9)
    at eval (/Users/wanzixin/study/MyBlog/themes/minos/layout/common/article.ejs:29:12)
    at article (/Users/wanzixin/study/MyBlog/node_modules/ejs/lib/ejs.js:682:17)
    at _View._compiledSync (/Users/wanzixin/study/MyBlog/node_modules/hexo/lib/theme/view.js:132:24)
    at _View.renderSync (/Users/wanzixin/study/MyBlog/node_modules/hexo/lib/theme/view.js:59:25)
    at Object.partial (/Users/wanzixin/study/MyBlog/node_modules/hexo/lib/plugins/helper/partial.js:34:15)
    at eval (/Users/wanzixin/study/MyBlog/themes/minos/layout/post.ejs:12:17)
    at post (/Users/wanzixin/study/MyBlog/node_modules/ejs/lib/ejs.js:682:17)
    at _View._compiled (/Users/wanzixin/study/MyBlog/node_modules/hexo/lib/theme/view.js:136:50)
    at _View.render (/Users/wanzixin/study/MyBlog/node_modules/hexo/lib/theme/view.js:39:17)
    at /Users/wanzixin/study/MyBlog/node_modules/hexo/lib/hexo/index.js:64:21
    at tryCatcher (/Users/wanzixin/study/MyBlog/node_modules/bluebird/js/release/util.js:16:23)
    at /Users/wanzixin/study/MyBlog/node_modules/bluebird/js/release/method.js:15:34
    at RouteStream._read (/Users/wanzixin/study/MyBlog/node_modules/hexo/lib/hexo/router.js:47:5)
    at RouteStream.Readable.read (internal/streams/readable.js:481:10)
    at resume_ (internal/streams/readable.js:977:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

In addition, when I use hexo g, I get such a error, and there are many such errors like this:

ERROR Error: /Users/wanzixin/study/MyBlog/themes/minos/layout/layout.ejs:4
    2| <html class="has-navbar-fixed-top">
    3| <head>
 >> 4|     <%- partial('common/head') %>
    5| </head>
    6| <body>
    7|     <%- partial('common/navbar', { page }) %>

/Users/wanzixin/study/MyBlog/themes/minos/layout/common/head.ejs:2
    1| <meta charset="utf-8">
 >> 2| <title><%= page_title() %></title>
    3| <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    4| 
    5| <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/outdated-browser/1.1.5/outdatedbrowser.min.css">

Function yaml.safeLoad is removed in js-yaml 4. Use yaml.load instead, which is now safe by default.
    at Object.safeLoad (/Users/wanzixin/study/MyBlog/node_modules/js-yaml/index.js:10:11)
    at getThemeConfig (/Users/wanzixin/study/MyBlog/themes/minos/scripts/99_config.js:33:37)
    at Object.<anonymous> (/Users/wanzixin/study/MyBlog/themes/minos/scripts/99_config.js:56:9)
    at Object.<anonymous> (/Users/wanzixin/study/MyBlog/themes/minos/scripts/99_content.js:78:20)
    at eval (/Users/wanzixin/study/MyBlog/themes/minos/layout/common/head.ejs:12:26)
    at head (/Users/wanzixin/study/MyBlog/node_modules/ejs/lib/ejs.js:682:17)
    at _View._compiledSync (/Users/wanzixin/study/MyBlog/node_modules/hexo/lib/theme/view.js:132:24)
    at _View.renderSync (/Users/wanzixin/study/MyBlog/node_modules/hexo/lib/theme/view.js:59:25)
    at Object.partial (/Users/wanzixin/study/MyBlog/node_modules/hexo/lib/plugins/helper/partial.js:34:15)
    at eval (/Users/wanzixin/study/MyBlog/themes/minos/layout/layout.ejs:12:17)
    at layout (/Users/wanzixin/study/MyBlog/node_modules/ejs/lib/ejs.js:682:17)
    at _View._compiled (/Users/wanzixin/study/MyBlog/node_modules/hexo/lib/theme/view.js:136:50)
    at _View.render (/Users/wanzixin/study/MyBlog/node_modules/hexo/lib/theme/view.js:39:17)
    at /Users/wanzixin/study/MyBlog/node_modules/hexo/lib/theme/view.js:51:25
    at tryCatcher (/Users/wanzixin/study/MyBlog/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/wanzixin/study/MyBlog/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/wanzixin/study/MyBlog/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/wanzixin/study/MyBlog/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/wanzixin/study/MyBlog/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/wanzixin/study/MyBlog/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/wanzixin/study/MyBlog/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/wanzixin/study/MyBlog/node_modules/bluebird/js/release/async.js:102:5) {
  path: '/Users/wanzixin/study/MyBlog/themes/minos/layout/layout.ejs'
}

I think there must be something wrong that led to such a mistake, but I can't seem to find it.

@wanzixin
Copy link
Author

@ppoffice I moved .config.zh-cn.yml file from the theme folder to the top folder. Now I can see some effects, but the menu bar still won't change the language. Is there any wrong with my settings?

image

/myblog/themes/minos/.config.yml
menu:
  Archives: /archives
  Categories: /categories
  Diary: /categories/Diary
  Gallery: /categories/Gallery
  Study: /categories/Study
  Item: /categories/Item
  About: /about

/myblog/.config.zh-cn.yml
menu:
  归档: /archives
  分类: /categories
  日记: /categories/Diary
  画廊: /categories/Gallery
  学习: /categories/Study
  项目: /categories/Item
  关于: /about

@ppoffice
Copy link
Owner

It's _config.yml and _config.zh-CN.yml.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
discussion Any questions about this theme.
Projects
None yet
Development

No branches or pull requests

2 participants