R
R
Raper992017-02-07 07:42:47
JavaScript
Raper99, 2017-02-07 07:42:47

How to set up a static site generation with two locales in gulp?

Good afternoon!
There is a site, completely static - html, css and some javascript. Broken down into Jade templates, built with gulp.
Not so long ago, there was a need to localize it into another language, leaving at the same time the Russian version.
After weighing all the implementation options, I came to the conclusion that the templates in a good way should remain common, and the information provided in them is different. I would like to split the structure so that in the main template one or another include from the directory of the corresponding locale is connected through the control logic, and at the output it is placed in out / en and out / ru, respectively.
Tell me how this can be implemented at the collector level and at the jade level. In a good way, without that when gulp-watchers are launched, both locales are collected into statics at once, if changes occur in the layout, so as not to edit each separately.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Khokhlov, 2017-02-07
@Raper99

You can pass data to jade templates when compiling.
To get started, do 2 tasks to build templates:

gulp.task('templates:ru', (cb) => {
  gulp.src(config.src)
    .pipe(jade({
      data: dataRu,
    }))
    .pipe(gulp.dest(config.destRu))
    .on('end', () => {
      cb(null);
    });
});

gulp.task('templates:en', (cb) => {
  gulp.src(config.src)
    .pipe(jade({
      data: dataEn,
    }))
    .pipe(gulp.dest(config.destEn))
    .on('end', () => {
      cb(null);
    });
});

And a watcher for these files, which will run both tasks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question