thiagorossener / jekflix-template

A Jekyll theme inspired by Netflix. 🎬
https://jekflix.rossener.com/
Other
855 stars 1.18k forks source link

How to use translations if I add it to the translations.yml? #192

Open alibabagogogo opened 1 year ago

alibabagogogo commented 1 year ago

Hi, thanks a lot for sharing this theme. How to enable the translation between English and translated language? e.g. Chinese. I've added the content to the translations.yml already, but nothing is changed.

  1. Is there a way to explicitly change the language? like, setting up a button on the right-top corner.
  2. if no, it will be auto-enable based on what criteria? IP? browser setting? or what ?

Thanks in advance.

thiagorossener commented 1 year ago

Hi @alibabagogogo, great you enjoyed the theme. Translations should work automatically after editing the translation variables and build the site.

So, if you cloned the repo, make sure you created the translations.yml file inside src/yml folder. If you're using the gem, add the content from here in your _config.yml file.

The site should be translated on your next build after doing that. Let me know if you have any issues.

alibabagogogo commented 1 year ago

Hi @thiagorossener , thanks a lot for your immediate feedback.

I did 'get clone' from your repo at the very beginning and I forked it as well. There is a blank translations.yml file in src/yml folder. I added your samples with some changes on values.

I build the site by gulp and by bundle exec jekyll serve. Neither way works in translation. The values of site.yml etc. will be updated in _config.yml after rebuild, but I cannot tell there is anything changed related to translations.yml.

Sorry I'm new to the coding part, so if I describe the process as a layman, yeah, I am the layman.. .

If my understanding is correct, every time I rebuild the project, the *.yml in src/yml will be 'gethered' into _config.yml and it will be used as 'rules' to bulid pages in _site. If this is correct, where does the translation mappings stores after rebuilding?

say

{{ site.translations.text.comments | default: "Comments" }}

in _includes folder? translations.yml? Or other new source after build?

Thanks a lot for helping!