{"action":"closed","issue":{"url":"https://api.github.com/repos/vitkarpov/grunt-nunjucks-2-html/issues/13","labels_url":"https://api.github.com/repos/vitkarpov/grunt-nunjucks-2-html/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/vitkarpov/grunt-nunjucks-2-html/issues/13/comments","events_url":"https://api.github.com/repos/vitkarpov/grunt-nunjucks-2-html/issues/13/events","html_url":"https://github.com/vitkarpov/grunt-nunjucks-2-html/issues/13","id":68137969,"number":13,"title":"i18n","user":{"login":"ArmorDarks","id":4460311,"avatar_url":"https://avatars.githubusercontent.com/u/4460311?v=3","gravatar_id":"","url":"https://api.github.com/users/ArmorDarks","html_url":"https://github.com/ArmorDarks","followers_url":"https://api.github.com/users/ArmorDarks/followers","following_url":"https://api.github.com/users/ArmorDarks/following{/other_user}","gists_url":"https://api.github.com/users/ArmorDarks/gists{/gist_id}","starred_url":"https://api.github.com/users/ArmorDarks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArmorDarks/subscriptions","organizations_url":"https://api.github.com/users/ArmorDarks/orgs","repos_url":"https://api.github.com/users/ArmorDarks/repos","events_url":"https://api.github.com/users/ArmorDarks/events{/privacy}","received_events_url":"https://api.github.com/users/ArmorDarks/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-04-13T16:27:24Z","updated_at":"2015-04-26T18:57:56Z","closed_at":"2015-04-26T18:57:56Z","body":"Not crucial feature, but potentially Task should support i18n. At least, we'd be glad to i18n some of our projects based on that Task.\r\n\r\nIn current state, we have few options:\r\n\r\n1. Use target for defining locales, like so:\r\n\r\n  ``` coffee\r\n  module.exports = ->\r\n    @config 'nunjucks',\r\n      enUS:\r\n        options:\r\n          paths: '<%= path.source.layouts %>/'\r\n          data: '<%= data %>'\r\n        files: [\r\n          expand: true\r\n          cwd: '<%= path.source.layouts %>/'\r\n          src: ['{,**/}*.nj', '{,**/}*.html', '!{,**/}_*.nj']\r\n          dest: '<%= path.build.root %>/en-us/'\r\n          ext: '.html'\r\n        ]\r\n      de:\r\n        options:\r\n          paths: '<%= path.source.layouts %>/'\r\n          data: '<%= data %>'\r\n        files: [\r\n          expand: true\r\n          cwd: '<%= path.source.layouts %>/'\r\n          src: ['{,**/}*.nj', '{,**/}*.html', '!{,**/}_*.nj']\r\n          dest: '<%= path.build.root %>/de/'\r\n          ext: '.html'\r\n        ]\r\n  ```\r\n\r\n  Potential problems: a lot of code repetitions, since we have to define new targets.\r\n\r\n  Besides, there are some avoidable, but nasty issues with passing name of the current locale to the templates as variables and so on...\r\n\r\n2. Use additional option, which will be by default `false`, but could accept array of locales:\r\n\r\n  ``` coffee\r\n  module.exports = ->\r\n    @config 'nunjucks',\r\n      build:\r\n        options:\r\n          locales: [\r\n            'en-US'\r\n            'de'\r\n          ]\r\n          paths: '<%= path.source.layouts %>/'\r\n          data: '<%= data %>'\r\n        files: [\r\n          expand: true\r\n          cwd: '<%= path.source.layouts %>/'\r\n          src: ['{,**/}*.nj', '{,**/}*.html', '!{,**/}_*.nj']\r\n          dest: '<%= path.build.root %>/en-us/'\r\n          ext: '.html'\r\n        ]\r\n  ```\r\n\r\n  Each entry of `options.locales` will\r\n\r\n  1. Define into which subfolders should be generated pages\r\n  2. Inject global nunjucks variable, let's say, `locale` or `currentLocale` with name of current locale in loop, so it will be possible to use it in `<html lang='{{ locale }}'>`, hrefs and so on\r\n\r\n  Another side benefit is that users would be able to pass here  micro-template like `<%= locales %>`, which could be shared with other i18n-related tasks, like https://github.com/mozilla/grunt-i18n-abide\r\n\r\nIt's also would be great, if Task would have ability to optionally define base language, for which Task will put generated pages in root of `dest` directory , instead of `dest/<%= localeName %>` subfolder.\r\n\r\nWhole idea is quite raw. Maybe you have some better thought regarding it."}}