-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problem with translation strings for pages #59
Comments
I encountered this too but I forgot how I solved it! The problem is that Assemble processes page in order and only do the replacements when rendering the page. What you are seeing is that the translation works for page that have been processed before that current page but the ones after have not yet been replaced. |
Ok, so how I fixed this is I created a custom plugin registered on the |
Do you maybe have an example of this custom plugin? |
Here is the plugin I wrote for this: /**
* postprocess
* @param {Object} params
* @param {Function} callback
*/
var async = require('async');
var _ = require('lodash');
var options = {
stage: 'render:pre:pages'
};
module.exports = function (params, callback) {
'use strict';
var assemble = params.assemble;
var grunt = params.grunt;
var options = assemble.options.permalinks;
var pages = assemble.options.pages;
async.forEach(pages, function(page, next) {
// TODO: traversal of the data object to expand more than just the title property
page.data.title = _.template(page.data.title)(page.data);
grunt.verbose.ok('Pre-processed:'.yellow, page.dest);
});
callback();
};
module.exports.options = options; |
sorry for the late answer. wasn't able to try it until now but this works. thank you! |
hey, i have the same problem but i don't know how to build this plugin. Do you can explain how i can use your plugin? would be greatly appreciated. |
Hi guys,
i'm using this plugin quite heavily at the moment and am happy that it works for me almost 100%. So great work! I do have one compiling issue with the pages feature though.
I have around 8 pages which have a custom title. I'm generating the navigation out of the page titles:
in the json:
For around half of the pages the translation of the titles works but for some pages I get just the string rendered out into the navigation. So on some pages I get the following navigation:
FAQs | <%= i18n[language].H_I_02 %> | Contact | Newsletter
OR<%= i18n[language].H_I_01 %> | <%= i18n[language].H_I_02 %> | Contact | Newsletter
I'm not sure how this happened. All pages have the same implementation of the title string. Also weird that on the page itself the string is fine. So in this example above, if I'd click the weird string which is supposed to be press, the navigation shows correctly on the press page.
I tried to reduce the complexity of how the pages are rendered out (without sort, without url etc) but it's always the same result.
Do you have any idea what went wrong? In which area would I need to look, to fix this?
Thanks!
The text was updated successfully, but these errors were encountered: