Coder Social home page Coder Social logo

Comments (9)

LaurentGoderre avatar LaurentGoderre commented on June 9, 2024

I think you need to do fruits: <%= i18n[language].fruits %>.

from grunt-assemble-i18n.

eikawata avatar eikawata commented on June 9, 2024

That also does not work.

In my case, I have an array of objects stored in an external file as follows.

books.yml

books:
  - book:
      - title: Book Foo
      - description: foo foo
  - book:
      - title: Book Bar
      - description: bar bar

I want to do {{#each}} on the array inside Handlebars template, so I did

---
books: <%= i18n[language].books %>
---

{{#each books}}
  <h2>{{ book.title }}</h2>
  <p>{{ book.description }}</p>
{{/each}}

This #each helper just outputs an empty block, without even rendering <h2> or <p>. But I noticed that if I do {{#each en.books }} ... {{/each}} (without using YFM), it works fine. Isn't this a bug?

By the way, having to define a variable in YFM for each array I want to use is really cumbersome. It'd be nice if we could do something like just i18n.books.

from grunt-assemble-i18n.

LaurentGoderre avatar LaurentGoderre commented on June 9, 2024

The issue is that sometimes you need a string in a specific language, not necessarily the language of the page, that's why it is the way it is but we could have another variables to point to the current language object. Any idea?

from grunt-assemble-i18n.

jonschlinkert avatar jonschlinkert commented on June 9, 2024

@LaurentGoderre out of curiosity, in your projects, is there something you can point me to that shows how the languages created/formatted or otherwise converted to data so they can be used in templates as context?

from grunt-assemble-i18n.

LaurentGoderre avatar LaurentGoderre commented on June 9, 2024

We use a CSV that is then converted to the right data

https://github.com/wet-boew/wet-boew/blob/master/src/i18n/i18n.csv
https://github.com/wet-boew/wet-boew/blob/master/Gruntfile.coffee#L1263-L1274

from grunt-assemble-i18n.

LaurentGoderre avatar LaurentGoderre commented on June 9, 2024

Although I would much prefer to handle this through Transifex

from grunt-assemble-i18n.

jonschlinkert avatar jonschlinkert commented on June 9, 2024

great, thanks for the info. I'm going to look into it a bit, hopefully I can make some of this easier in assemble.

from grunt-assemble-i18n.

LaurentGoderre avatar LaurentGoderre commented on June 9, 2024

The biggest issue I saw with this and assemble is when using the function like navigation. I had to preprocess the front-matter for all files to make sure the i18n substitution was happening other wise I would get this for the first file

Link 1
i18n(link2)
i18n(link2)
``
And this for the second file:

Link 1
Link 2
i18n(link2)
``

And so on

from grunt-assemble-i18n.

jonschlinkert avatar jonschlinkert commented on June 9, 2024

yeah, I think that would be expected with front matter in general - since that data won't be on the context until it's actually parsed. with 0.6 this is a lot easier, and we have several options to ensure you don't have that issue anymore. let me know if you want to review sometime

from grunt-assemble-i18n.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.