-
Notifications
You must be signed in to change notification settings - Fork 203
Easier README.md #5
Comments
Hi @davrandom Thank you for your feedback, I'm aware that the documentation can be much better and Im happy to get some help. If you are willing to create a minimal multilingual website I will happily merge it in to the main branch. The answer to you specific question however I can answer: {% if site.lang == "sv" %}
{% capture link1 %}{{ site.baseurl_root }}/en{{ page.url}}{% endcapture %}
<a href="{{ link1 }}" >{% t global.english %}</a>
{% else if site.lang == "en" %}
{% capture link2 %}{{ site.baseurl_root }}{{ page.url }}{% endcapture %}
<a href="{{ link2 }}" >{% t global.swedish %}</a>
{% endif %} This snippet will create a link that will toggle between Swedish and English. The interesting variables are:
There you have it, I will merge this in to the main readme, please tell me if you have any other problems. |
Can I close this issue? |
Thanks for replying so quickly!
etc... 2 - I should use a header like:
for italian,
for english, etc. 3 - Where should I put something like your snippet code? Thanks for your help |
Ok now I understand your problem a bit more. The plugin does not handle translated posts (even though this would be a nice addition and probably quite easy to add) but aims for you not have to duplicate your layouts and includes. I would use the category feature in Jekyll to be able to separate the different languages in the posts. Like this:
etc... 2 - I should use a header like:
for italian,
for english, etc. The resulting pages are, for example: This is possible and you can create links that goes from one post to another with the same name in the layout files using the snippet I posted before. Can you write a second issue about the missing post feature and explain how you want it to work? |
You can add this completely untested monkey patch to the multiple languages and it should probably pick up the language folder in the posts directory: def read_posts(dir)
posts = read_things(dir, '_posts/#{self.config['lang']}', Post)
posts.each do |post|
if post.published && (self.future || post.date <= self.time)
aggregate_post_info(post)
end
end
end Paste the snippet just before end
class LocalizeInclude < Jekyll::Tags::IncludeTag |
Please tell me if it worked @davrandom |
So, for what concerns the part related to this plugin, if I follow what you suggested and I add in my _layouts/posts.html you snippet code I get a: In my local site it doesn't work anyway. |
Check out my commit https://github.com/screeninteraction/davrandom.github.io/commit/bbe2f57a1712496570676928f8f875419a29ac42 for an example of a translated string |
Hi, I'm very new to jekyll (at the moment I'm working locally, migrating my textpattern website to jekyll).
I would really love to be able to manage multiple languages (it, en, es). The problem that I'm facing is that for a jekyll-newbie your readme is a bit too short. In particular -imho- is lacking some friendliness in the "usage" side. I cannot figure out how to link two posts that are the translated versions of the same post.
Maybe a minimal multilingual example website could help.
I hope I'm not alone :D
Thanks for your time
d
The text was updated successfully, but these errors were encountered: