felixzapata / gulp-i18n-pug

Gulp plugin to compile Pug templates with internationalization support based on JS/JSON/YAML files
MIT License
28 stars 4 forks source link

Some problems with path to dest #2

Closed Dukeskes closed 7 years ago

Dukeskes commented 7 years ago

My working gulp task

gulp.task('pugi18n', function () {
    var options = {
        i18n: {
            dest: path.resolve(APP_BASE.HTML),
            namespace: '$t',
            locales: APP_BASE.LOCALES,
            localeExtension: false
        },
        client: false
    };
    return gulp.src(APP_PATHS.PUG)
        .pipe(pugI18n(options))
        .pipe(gulp.dest("./1/2/3"));
});

Something is wrong in your:

 compiledFiles.push(new gutil.File({
                    base: path.join(__dirname, locale),
                    cwd: __dirname,
                    contents: new Buffer(pug.compileFile(file.path, options)(options.data)),
                    path: path.join(options.i18n.dest, dest)
                }));

While im leaving base, and cwd path commented, the path in properties are working properly, but when im leaving your code not touched i have to add 3 fake folder because it going to 3 locations up

<File "../../../html/en/index.html" <Buffer 3c 21 44 4f 43 54 59 50 45 20 68 74 6d 6c 3e 3c 68 74 6d 6c 3e 3c 68 65 61 64 3e 3c 6d 65 74 61 20 63 68 61 72 73 65 74 3d 22 75 74 66 2d 38 22 3e 3c ... >>

So probably your path is broken

base: path.join(__dirname, locale), cwd: __dirname,

felixzapata commented 7 years ago

hi @Dukeskes, I will take a look as soon as possible.

felixzapata commented 7 years ago

hi @Dukeskes. So, with this code:

compiledFiles.push(new gutil.File({
                    base: path.join(__dirname, locale),
                    contents: new Buffer(pug.compileFile(file.path, options)(options.data)),
                    path: path.join(options.i18n.dest, dest)
                }));

your code works? I've checked with my current tests too, and I think the cwd option can be removed.

ursereg commented 7 years ago

I have probably same problem. It currently works like this, at least for me:

compiledFiles.push(new gutil.File({
    base: path.join(__dirname, locale),
    cwd: __dirname,
    contents: new Buffer(pug.compileFile(file.path, options)(options.data)),
    path: path.join(path.join(__dirname,options.i18n.dest), dest)
}));
felixzapata commented 7 years ago

@Dukeskes do you still have problems with the plugin?

Dukeskes commented 7 years ago

When i deleted cwd options, everything gone well, as i wrote in my first message :)

felixzapata commented 7 years ago

Ok, in this case I will release a new version with the update

felixzapata commented 7 years ago

@Dukeskes @ursereg I´ve released version 1.0.1