решено включением углового gettext
gulpfile:
const gulp = require('gulp');
const gettext = require('gulp-angular-gettext');
gulp.task('extract', function () {
return gulp.src(['src/**/*.html', 'src/**/*.js'])
.pipe(gettext.extract('template.pot'))
.pipe(gulp.dest('translations/'));
});
gulp.task('translations', function () {
return gulp.src(['translations/*.po'])
.pipe(gettext.compile({
format: 'json'
}))
.pipe(gulp.dest('src/i18n'));
});
JS
const fs = require('fs');
const phrases = JSON.parse(fs.readFileSync('src/i18n/zh.json', 'utf8'));
const gettext = (text) => phrases.zh[text] || text;
Twig.extendFilter('translate', gettext);
декорирование
js -
page().find('.dashboard-mentions').html(gettext("You haven't been mentioned yet."));
HTML -
<h4 class="text-label">{{ 'Title *' | translate }}</h4>