Coder Social home page Coder Social logo

Comments (6)

LaurentGoderre avatar LaurentGoderre commented on June 9, 2024

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.

from grunt-assemble-i18n.

LaurentGoderre avatar LaurentGoderre commented on June 9, 2024

Ok, so how I fixed this is I created a custom plugin registered on the render:pre:pages stage loops through all the page and perform the replacement manually for the title. It kinds of bypass this plugin just for titles.

from grunt-assemble-i18n.

lhtdesignde avatar lhtdesignde commented on June 9, 2024

Do you maybe have an example of this custom plugin?

from grunt-assemble-i18n.

LaurentGoderre avatar LaurentGoderre commented on June 9, 2024

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;

from grunt-assemble-i18n.

lhtdesignde avatar lhtdesignde commented on June 9, 2024

sorry for the late answer. wasn't able to try it until now but this works. thank you!

from grunt-assemble-i18n.

d-rogaczewski avatar d-rogaczewski commented on June 9, 2024

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.

from grunt-assemble-i18n.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.