-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need help on Internationalization (i18n) (Critical) #3247
Comments
No one checked this? So how can we get support on Hexo if the supporting is so bad? The documentation is really really bad, we definitely cannot follow. It's really critical for me! |
Yeah @hachi1030-Allen it can be very difficult. We need more people to help! i18n is difficult for everyone and it's not clear the best way to use it. Thankfully hexo is so flexible you can roll your own if the default functionality doesn't work for you. One project with good i18n is theme-next https://github.com/theme-next/hexo-theme-next Also fork my project here for very advanced i18n support. I did examples with EN, DE, and ZH-HK. https://github.com/tcrowe/learn-plasma |
Did you push the source code of your blog on GitHub? That would help us see and understand your full config |
Hi Tony, Thanks for the reply. Since it's been a while, I had to use the another blog theme. You can check my needs on the i18n from my current blog: http://liudeyun.net. I checked on your GitHub link for the theme next, but I did not see any sample blog there is having the i18n feature. Please check mine, I had 2 languages for same blog. I just want to know, assume that I would like to develop my own theme, what is the best practice to implement i18n? Thanks, Allen |
Good to hear back @hachi1030-Allen Your site looks good. 👍🏼 Assuming unix To make an i18n theme add to # main language
language: zh-cn
# all supported languages
languages:
- zh-cn # <---primary at top
- en Create languages yaml directory:
Create yaml for each language i18n texts: touch themes/my-theme/languages/zh-cn.yml
touch themes/my-theme/languages/en.yml Edit 你好: 你好 Edit 你好: hello The key is Okay! Languages are ready to go. Now lets implement it inside the template: Edit <%= __('你好') %> That's it! Can you try and let me know if it worked? Here, this will generate a new theme very quickly. https://github.com/tcrowe/generator-hexo-theme |
You can also add the language to the layout template: <html lang="<%=config.language%>"> If not that try |
Pages and posts: ---
lang: en
title: ...
date: ...
--- -or- ---
lang: zh-cn
title: ...
date: ...
--- |
Hi Tony, Thanks for the reply! Looks like quite easy in your instructs, but as far as I learnt, it's not. Assume that I would like the same effect as in my blog: I can switch the language both in the root page and also blog post page. How can I implement this using the current i18n? Also, in my current theme, I have to follow the rules in that theme and there is definitely something bad. For my current folder structure, under my source_posts folder, I will have an additional folder named as zh-cn to put all my Chinese blogs, that's fine. But if I enable And since that theme do not have the en folder to put English articles, we just use the default folder which is source_posts to put them, so I cannot use the That's why I am asking do we have any best practice to achieve this kind of thing? Thanks, Allen |
It's a good idea to dig through each theme you see which has i18n. It goes something like this. <% config.theme.languages(lang => { %>
<div>lang: <%=lang%></div>
<% }) %> If you share the same assets between languages maybe its best to put them in
It's not clear to me how that should work in hexo or any static site generator. We do need clearer instructions about the i18n capabilities. One idea I had was to do something like this: You said you could not see it but try to look at these again on how to accomplish the |
I like your idea with |
Thanks for the reply. I totally agree with you. I am expecting 3 things actually:
Not sure whether it's possible or not. Thanks, Allen |
Also, yes, please make it as a feature request, I do think if we are going to use internationalization, we should be able to create blogs directly under correct folder using CLI. Thanks, Allen |
See also #1696 |
Environment Info
Node version(
node -v
): v8.9.4Your site
_config.yml
(Optional): Need to confirm with you on this.Your theme
_config.yml
(Optional): Need to confirm with you on this.Hexo and Plugin version(
npm ls --depth 0
):+-- hexo@3.7.1
+-- hexo-deployer-git@0.3.1
+-- hexo-generator-archive@0.1.5
+-- hexo-generator-category@0.1.3
+-- hexo-generator-feed@1.2.2
+-- hexo-generator-index@0.2.1
+-- hexo-generator-search@2.2.5
+-- hexo-generator-tag@0.2.0
+-- hexo-renderer-ejs@0.3.1
+-- hexo-renderer-marked@0.3.2
+-- hexo-renderer-njucks@1.0.0
+-- hexo-renderer-stylus@0.3.3
`-- hexo-server@0.3.3
For question
I really need some help from you guys on the i18n implementation.
I was trying to follow the blog: https://bluemix.github.io/en/2017/multilingual-blogging-with-Hexo/
After modifying the
new_post_name
to :lang/:title.md, I was able to create the md files in the seperate folders. However, there will be generate issue that my blogs are not generated correctly. The error message is something like:ENOENT no file or directory: path for some image.
.Please contact me back so that I can demonstrate to you guys on this error.
Also, I need to confirm one thing from you guys. If I enabled the international blogs for both Chinese and English language, do I have to match the articles? Is it possible that only the technical documents that I wrote, I will prepare 2 languages for that, but for others, I just create Chinese ones? The page will render or not?
Please contact back to me via: liu.allen1030@gmail.com as soon as possible. It's really critical for me.
Thanks,
Allen
The text was updated successfully, but these errors were encountered: