How to foreach list languages supports in express-handlebars
See original GitHub issueam use i18n for support multi languages.
- I can’t find documents for list languages pass to views.
{{#each languages}}
<li><button onclick="window.location.href='/{{this.langcode}}';" class="btn btn-link btn-block language-select" type="button" name="VN"><img src="/images/{{this.langcode}}.png" alt="{{this.langname}}" title="{{this.langname}}" /> {{this.langname}}</button></li>
{{/each}}
- how to get default data
Current i do static html:
<div id="language" class="btn-group">
<button class="btn-link dropdown-toggle" data-toggle="dropdown"> <span> <img src="/images/{{language}}.png" alt="Việt Nam" title="Việt Nam">{{langname}} <i class="fa fa-caret-down"></i></span></button>
<ul class="dropdown-menu">
<li>
<button onclick="window.location.href='/vi';" class="btn btn-link btn-block language-select" type="button" name="language"><img src="/images/vi.png" alt="Việt Nam" title="Việt Nam" /> Việt Nam</button>
</li>
<li>
<button onclick="window.location.href='/en';" class="btn btn-link btn-block language-select" type="button" name="GB"><img src="/images/en.png" alt="English" title="English" /> English</button>
</li>
</ul>
</div>
thankyou any solution
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Node.js express, handlebars - get elements of an array
First of all, lets assume that your files:items is a handlebar'd array looking kinda like this. { files:['filenameOne.ext', 'filenameTwo.ext', ...
Read more >Built-in Helpers - Handlebars
You can iterate over a list using the built-in each helper. Inside the block, you can use this to reference the element being...
Read more >Express i18n with handlebars and maintainable links - Medium
i18n consists of making every text in your site a variable and every time the page is requested in certain language, every variable...
Read more >Using Handlebars with Express | Packt Hub
Node.js and Express, support several templating languages that allow you to separate layout and content, and which have the template system ...
Read more >foundersandcoders/express-handlebars-workshop - GitHub
Contribute to foundersandcoders/express-handlebars-workshop development by ... over the fruits array (similarly to javascript's forEach array method).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
erm, I think the easiest way is adding those to your translations like
en.json
de.json
and using i18n helper to display (example in hbs)
use
i18n.getLocales()
https://github.com/mashpie/i18n-node#i18ngetlocales and pass the result tolocals
of your view.for one view only
or more generally for all view by middleware