iissnan / hexo-theme-next

Elegant theme for Hexo.
http://notes.iissnan.com
MIT License
15.87k stars 3.63k forks source link

[Feature Request]: Add a language-switch button in NexT #1680

Open Gabirel opened 7 years ago

Gabirel commented 7 years ago

Expected behavior (预期行为)

希望可以像https://hexo.io 那样有个可以多国语言切换的按钮

现在支持这种开箱即用的主题好像没有,NexT能否支持呢?

虽然可以在文章里添加链接这种形式,但是过于麻烦了,官方能否支持一下?


English: I hope Next could have a button like https://hexo.io to help users to switch languages.

Could Next support this since others themes don't have this kind of feature.

It is too inconvenient to add a link inside the articles though users could do it.


NexT Information

Add the ✔ sign before an item which is affected by this behavior.

NexT Scheme:

AlynxZhou commented 7 years ago

hexo.io那个是生成了多语言的网页放在了子目录?感觉这个跟NexT主题没啥关系……是hexo生成的问题吧,hexo一次只能生成一个语言的,主题应该改不了这个吧。

Gabirel commented 7 years ago

现在的hexo版本可以生成多语言目录,已经做到了(我博客现在就是有多语言的文章),就差NexT主题支持多语言切换按钮了

Haocen commented 6 years ago

The multi-language support user asked for is actually a limitation of Hexo, not necessary this theme.

Gabirel commented 6 years ago

@Haocen What I mean is that it would be a awesome feature if there was a button for switching languages whenever visitors did that. Not just the multi-language support. I do know this feature was supported long time ago. All I need is that a button for switching languages.

The official website of Hexo has already included this feature. However, it is not easy for us who use NexT to make it happen since NexT doesn't have any feature like this.

Like this: image

Actually, I really want to do it by myself. But this is beyond my ability.

ivan-nginx commented 6 years ago

@AlynxZhou that's right, i want to do this, but always forgot. :smile:

stevenjoezhang commented 4 years ago

我不确定这个「多国语言切换的按钮」需要多智能? 举例用的 https://hexo.io 的按钮,在任何界面点击都会「回到首页」,而不是「跳转到与当前对应的页面」。

Gabirel commented 4 years ago

多语言切换需要的是可以对于当前页面直接切换,即「跳转到与当前对应的页面」。而非跳转到首页

其实已经有一些人已经实现了这样的功能。我之前收藏的URL,他们的域名都过期了,找不到了。如果找到了我会加进来。

stevenjoezhang commented 4 years ago

我想你说的是这个效果: https://dengcb.com/zh/page/2/ Pull Request已经有了: https://github.com/theme-next/hexo-theme-next/pull/1391 但是,Hexo默认的generator并不会为不同语言生成单独的首页和归档页面。你需要借助 https://github.com/Jamling/hexo-generator-i18n 这样的第三方插件,或者用不同的配置多次执行hexo g,否则「跳转到与当前对应的页面」可能失败:例如,只有中文归档页面,而没有英文归档页面,那么切换语言就会导致404 not found。这涉及到Hexo的核心功能,不是一个主题负责的范围,因此你需要自行解决。

AlynxZhou commented 4 years ago

我补充一下,Hexo的多语言支持其实是很不完整的:虽然可以添加多个语言,但是各种自带生成器都没考虑这个,如果生成器没有规划好路径,主题就没法处理跳转。所以与其依赖Hexo建立多语言网站,不如建立多个Hexo站点,每个站点处理一种语言,然后将它们设置为不同的subdir,之后添加一个统一首页即可,然后自己修改一下主题添加链接。因为反正不管怎么处理,你都要编写多份不同语言博文,所以这样并没有太大影响。

stevenjoezhang commented 4 years ago

是的,自带生成器没有考虑这个问题,主题要集成多语言,只能暴力改: https://github.com/ppoffice/hexo-theme-minos/commit/f0269850ab83fba1200457c40d9e59c49a027fe4 期望 Hexo 在未来提供统一的接口: https://github.com/hexojs/hexo/issues/1125#issuecomment-592967293