kurtsson / jekyll-multiple-languages-plugin

I18n support for Jekyll and Octopress
MIT License
925 stars 202 forks source link

Is it possible to translate objects in front matter? #67

Open pklada opened 8 years ago

pklada commented 8 years ago
subnav:
  - name: subtitle.overview
    hash: overview
  - name: subtitle.examples
    hash: examples
  - name: subtitle.builder
    hash: builder
  - name: subtitle.resources
    hash: resources

This is something we're trying to do (define the navigation in the front matter) but the 'name' keys here aren't being translated (just shows up as a literal string).

Anthony-Gaudino commented 8 years ago

Hi @pklada, I didn't understand exactly what you want to achieve.

If you want to provide translations on the front matter, then currently this is not possible, the translation tag provided on the plugin only searches on YAML files in the _i18n folder.

So if you use {% t page.subnav[2]["name"] %} it wont return subtitle.builder.

If I misunderstood you, please let me know.

anroots commented 8 years ago

A use case for this would be to translate key-value attributes in a web-shop site:

---
name: Pineapples
price: 50

As the owner of that hypothetical site, I would like to present my product names in two different languages. The easiest way for me to do that would be to translate the name string in the front matter and that string only (I want to keep things DRY, so duplicating the price attribute would be an anti-pattern)

ghost commented 6 years ago

hello there, is it possible to access yml files in the language folders (en/es/de/...) and loop the current language versions in the yml file ? Thanks