Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Refactor multilanguage implementation #31

Merged
merged 5 commits into from
Dec 21, 2018
Merged

Conversation

sauloperez
Copy link
Contributor

@sauloperez sauloperez commented Dec 5, 2018

Description

I refactored the site to use jekyll-multiple-languages-plugin. This plugin adds a folder for each language defined in config. As a result we moved all posts to each language folder so that we keep the current behavior of mixing languages.

Now, to add new pages we'll have to add the template plus its translations. That is, about.html with a call to translate_file, plus the files _i18n/ca/about.md and _i18n/es/about.md.

Then, all translation keys live in either _i18n/ca.yml and _i18n/es.yml.

⚠️ Something I just realized is that

The main administrator @Anthony-Gaudino, has disappeared so we are in a bit of a sad state here. I still have access to the Ruby Gem and can release new versions but I do not use any Jekyll sites and have no way of verifying PRs. In short this project really need a new owner, is that you? Or can you atleast verify all PRs so I can merge and make a release?

Source: kurtsson/jekyll-multiple-languages-plugin#125 (comment)

After seeing people using home-made solutions and other plugins I can tell this is one seems the best to me. Even, if we need to, we could mess with the code. It's not a big deal.

See more details in: Anthony-Gaudino/jekyll-multiple-languages-plugin

Fixes

I also took the chance to fix Seguir leyendo. We were displaying it in both Catalan and Spanish. Now that's translated.

@sauloperez sauloperez changed the title Refactor multilanguage Refactor multilanguage implementation Dec 5, 2018
@sauloperez sauloperez mentioned this pull request Dec 5, 2018
Gemfile Outdated
@@ -9,6 +9,7 @@ source "https://rubygems.org"
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
gem "jekyll", "~> 3.7.2"
gem 'jekyll-multiple-languages-plugin'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can specify the version, no?
And we can use also the " as in the previous line.

gem "jekyll-multiple-languages-plugin", "~> 1.6"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!


<div class='project'>
<div class='logo'>
<img src='{{ "/assets/img/projects/katuma.png" | prepend:site.baseurl }}' width='140' height='140' />
</div>
<div class='description'>
{{ page.katuma_description | markdownify }}
{% t page.katuma_description %}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, markdownify doesn't work with {% %} tags so we need to write these translations in HTML instead.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you markdownify in an assign variable and then use it? Would that work?

Copy link
Contributor Author

@sauloperez sauloperez Dec 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried and it doesn't. Looks like you can't use filters there either.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So do a helper in Ruby that use markdownify. I think Jekyll has helpers a la Rails

Copy link
Contributor Author

@sauloperez sauloperez Dec 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I thought about that. Or even open a PR against that plugin to allow for this but I don't think it's a big deal now. We were just markdownifying couple links and a <strong>.

We can create an issue for it in the future though if things get painful.

@enricostano
Copy link
Contributor

Is this Jekill plugin supported by GH Pages?

@sauloperez
Copy link
Contributor Author

That's a good point. It just adds extra build steps but I'm not sure how that relates to GH's build process... I bet not very well... 🙈

@andresgutgon
Copy link

The build can happen in your machine. It should not be a problem afaik

@sauloperez sauloperez mentioned this pull request Dec 10, 2018
@sauloperez
Copy link
Contributor Author

We'll need to do #33 first.

@enricostano
Copy link
Contributor

enricostano commented Dec 11, 2018

The build can happen in your machine. It should not be a problem afaik

In that case we loose the automated build/deploy on code change, that's the main selling point of GH pages IMHO.

This is why I started to investigate how to support Jekyll deploys on our servers: https://github.com/coopdevs/coopdevs-provisioning/blob/master/roles/coopdevs.org/files/post-receive

It works, but we still don't use it.

@andresgutgon
Copy link

What about Netlify? It's more flexible than Gh pages

@andresgutgon
Copy link

Anyway this it's juat build in local machine and push to gh-pages branch. Not hard to implement. Does people change content on this side from GitHub UI? If all the changes are done by a developer I would stick with Gh pages

@enricostano
Copy link
Contributor

What about Netlify? It's more flexible than Gh pages

This is why I stopped investigating our solution, I wanted to try Netlify.... but, you know... time...

If all the changes are done by a developer I would stick with Gh pages

We have/want more people than developers to be able to contribute to our projects, that's why I would keep the build and deploy automation in place.

This plugin adds a folder for each language defined in config. As
a result we moved all posts to each language folder so that we keep the
current behavior of mixing languages.

Now, to add new pages we'll have to add the template plus its
translations. That is, about.html with a call to `translate_file`,
_i18n/ca/about.md and _i18n/es/about.md.

Then, all translation keys live in either _i18n/ca.yml and _i18n/es.yml.

See more details in:
https://github.com/Anthony-Gaudino/jekyll-multiple-languages-plugin
`jekyll-multiple-languages-plugin` is better designed than our naive
redirect to /ca and allows us to fix bugs we already have.

Unfortunately tag markup ({% %}) doesn't work with filters so `|
markdownify` can't be used anymore. We use translation keys instead.
@sauloperez sauloperez changed the base branch from master to develop December 21, 2018 11:26
@sauloperez sauloperez self-assigned this Dec 21, 2018
@sauloperez sauloperez merged commit 8a86035 into develop Dec 21, 2018
@sauloperez sauloperez deleted the refactor-multilanguage branch December 21, 2018 11:44
@sauloperez
Copy link
Contributor Author

Up & Running 🎉 !

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

Successfully merging this pull request may close these issues.

4 participants