Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- en: {
- name: "english name",
- content: "english content"
- },
- it: {
- name: "italian name",
- content: "italian content"
- },
- //since images are the same for both, are not nested
- images: {
- mainImage: "dataURL",
- mainThumb: "dataURL"
- }
- }
- Meteor.publish("elementsCurrentLang", function(currentLang) {
- var projection = {
- images: 1
- };
- projection[currentLang] = 1;
- return Elements.find({}, projection);
- });
- Router.route('/eng/elements', {
- waitOn: function() {
- return Meteor.subscribe("municipalitiesCurrentLang", Session.get('currentLang'));
- },
- action: function() {
- this.layout('ApplicationLayout');
- this.render('elements');
- }
- });
- Template.elements.helpers({
- elements: function() {
- var elements = Elements.find();
- var currentLang = Session.get('currentLang');
- var resultList = [];
- elements.forEach(function(element, index) {
- var element = {
- name: element[currentLang].name,
- content: element[currentLang].nameUrl,
- images: element.images
- };
- resultList.push(element);
- });
- return resultList;
- }
- });
- <h1>{{name}}</h1>
- <p>{{content}}</p>
- en.i18n.json:
- {
- "hello": "hello"
- }
- fr.i18n.json:
- {
- "hello": "bonjour"
- }
- {{_ "hello" }}
- TAPi18n.setLanguage(getUserLanguage())
- //getUserLanguage() <- my function to get the current langage in the user profile or
- the one used by the navigator
Add Comment
Please, Sign In to add comment