Closed albpara closed 7 years ago
hi @albpara, I will take a look as soon as possible.
hi @albpara, your example it works for me. Can you show me your translation and pug files?
Thaks for the reply Felix. This is my pug:
div #{$t.helloworld}!
p Using locale #{$localeName}
de.yml
helloworld: 'Hallo welt'
en.yml
helloworld: 'Hello world'
Just tested again, I noticed that the translations are created on the wrong place
My project path is /home/xxxxx/development/my-fe-project
so gulpfile.js is on /home/xxxxx/development/my-fe-project/gulpfile.js
The translations are created under development
folder no inside my-fe-project
The gulps task is defined as follows(sorry I changed it a little, only the paths):
gulp.task('dev:compile:pug:i18n', function (done) {
var options = {
i18n: {
dest: './app-dev/translation',
locales: './app/locales/*'
},
pretty: true
}
return gulp.src(paths.pugSrc)
.pipe(pug(options))
.pipe(gulp.dest(options.i18n.dest));
});
The locales path is interpreted correctly with ./
but not the dest path which is created one level "behind"
hi @albpara, I tested your example with the same routes and the dest
folder was created under the directory of the gulp
file.
Dunno what to test... I am not able to make it work, but if is working for you I suppose that is just a problem with my configuration, I will try to figure out what is wrong.
Ok, contact me again if it does not make it work
Same issue here. The compiled files are two directories before the current path.
If I'm in ./one/foo/bar/website
with a dest
to ./.tmp
, the compiled files are written in ./one/.tmp
.
I've tried some workarounds with path
, __dirname
process.cwd()
but nothing works.
OS: macOS Node.js: v8.4.0 npm: v5.3.0
Related to #2
hi @mytototo , can you send your gulp task?
Also having exactly the same issue as described above. It seems to have something to do with the base
parameter in line 168. When I change the line from base: path.join(__dirname, locale),
to base: options.i18n.dest,
everything works as expected for me.
This is my task code:
const PATHS = {
dist: 'dist',
templates: 'src/templates/*.pug'
}
gulp.task('translate-templates', () => {
const options = {
i18n: {
dest: PATHS.dist,
locales: `${PATHS.dist}/translations/*.json`,
localeExtension: false
}
}
return gulp.src(PATHS.templates)
.pipe(pugI18n(options))
.pipe(gulp.dest(PATHS.dist))
})
hi @fschucht , your code it is works for me. In order to test it, I've created this folder structure based in your gulpfile.js
(is it the same than yours?):
the gulpfile.js
var gulp = require('gulp');
var pugI18n = require('gulp-pug-i18n');
const PATHS = {
dist: 'dist',
templates: 'src/templates/*.pug'
}
gulp.task('translate-templates', () => {
const options = {
i18n: {
dest: PATHS.dist,
locales: `${PATHS.dist}/translations/*.json`,
localeExtension: false
}
}
return gulp.src(PATHS.templates)
.pipe(pugI18n(options))
.pipe(gulp.dest(PATHS.dist))
})
the pug
file:
body
div
h1 #{$i18n.message}
h2 #{$i18n.nested.msg}
the es_ES.json
file
{
"message": "Hola Mundo!",
"nested": {
"msg": "y hola a tí también"
}
}
the en_US.json
file
{
"message": "Hello world!",
"nested": {
"msg": "and hello to you"
}
}
The result:
The template.en.html
file
<body><div><h1>Hello world!</h1><h2>and hello to you</h2></div></body>
The template.es.html
file
<body><div><h1>Hola Mundo!</h1><h2>y hola a tí también</h2></div></body>
Hey @felixzapata. Thanks for your help! I see the error. I used gulp-i18n-pug
(as the name of the git would suggest) rather than gulp-pug-i18n
which you are using. With the latter it works. Maybe it should be mentioned in the readme which version should be installed?
With gulp-pug-i18n
however I have a new problem. The localeExtension
option is getting ignored and files are always compiled with the locale as a extension. This is also the case in your test. I will create a new issue for this.
I will update the README
. I had to change the repository name when I wanted publish the plugin because the name already did exist.
I will take a look to the other issue so I will close this one.
hi @fschucht I´m going to reopen the issue because I made a mistake about the name of the plugin. The name I used in my previous comment it is not the correct (it was not my plugin). There are two plugins almost with the same name, so I´m going to test again your folder structure.
Sorry for that.
Hi @fschucht , I've released the version 1.0.2 with the fix.
$ npm install gulp-i18n-pug --save-dev
My gulp task is not generating any output files. This is my task code:
The gulp task output seem to "reach" the pug files:
But no output files are saved