Comments (9)
I think you need to do fruits: <%= i18n[language].fruits %>
.
from grunt-assemble-i18n.
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.
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.
@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.
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.
Although I would much prefer to handle this through Transifex
from grunt-assemble-i18n.
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.
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.
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)
- "with-plugin" task fails: No source files found HOT 2
- Add documentation HOT 30
- Warning: The 'language' parameter is not defined HOT 16
- Stack overflow on language in front matter HOT 4
- Out of memory on compilation HOT 26
- Keep folder structure inside language folder? HOT 4
- Complementary plugin (shameless plug :P) HOT 2
- Convert to assemble v0.6.0 HOT 2
- Suggestion: make replacement of page file name optional HOT 18
- Duplicate Navigation generated in within partials HOT 4
- v0.1.3
- README.md cannot be generated using Verb HOT 4
- Allow language files to be divided or data to be nested HOT 6
- language not being set HOT 7
- i18n navigation HOT 6
- problem with translation strings for pages HOT 6
- Moving to `grunt-assemble-i18n` HOT 2
- `i18n` helper inside `each` helper results in: The 'language' parameter is not defined HOT 16
- moderate severity security vulnerability on handlebars dependency HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-assemble-i18n.