gabegorelick / gulp-angular-gettext Goto Github PK
View Code? Open in Web Editor NEWGulp plugin for extracting/compiling angular-gettext strings. http://angular-gettext.rocketeer.be/
License: MIT License
Gulp plugin for extracting/compiling angular-gettext strings. http://angular-gettext.rocketeer.be/
License: MIT License
Re https://github.com/gabegorelick/gulp-angular-gettext/blob/master/lib/extract.js#L81
Why is it doing this?
It would be nice to be able to detect strings to translate base on a special comment placed before instead of requiring to wrap into a gettext()
function call.
e.g.
const myTranslatagleString = /* @ngTranslate */ "My String"
return gettextCatalog.getString(myTranslatagleString)
Hi,
I cannot find the way to maintain the old translations and not overwrite them everytime.
this is my code
gulp.task('translations:parse', function () {
return gulp.src([conf.paths.src + '/app/**/*.html', conf.paths.src + '/app/**/*.js'])
.pipe(gettext.extract('translations.pot', {}))
.pipe(gulp.dest(conf.paths.src + '/app/translations/'));
});
So the first time the file "translations.pot" is generated. If I translate directly in this file, and I run gulp translations:parse
again, the translations saved in "translations.pot" will be lost.
So let's say I have in translations.pot
#: partials/home.html:3
msgid "Welcome"
msgstr "Bienvenido"
After running gulp translations:parse
again, the translations are lost
#: partials/home.html:3
msgid "Welcome"
msgstr ""
Is there any possible solution for that? How can I save the old translations?
Thanks a lot
Adrián Bolonio
Hi, I would like to see streaming support!
Thank you.
gulp-angular-text is using gulp-util, which is deprecated.
gutil.File and gutil.PluginError should be replace.
gutil.File => https://www.npmjs.com/package/vinyl
gutil.PluginError => https://www.npmjs.com/package/plugin-error
For more information
https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
Hey I have come across a very strange bug when using multiple attributes. I have a switch directive, within this I have a on attribute and a off attribute (what text to display when the switch is on and off).
If I have the attributes next to each other
<switch class="small"
checked="focused.settings.require
off="'global.no' | translate"
on="'global.yes' | translate"
>
gulp-angular-gettext does not see the second attribute
msgid "global.no"
msgstr ""
but if I have a attribute in between the two it does
<switch class="small"
off="'global.no' | translate"
checked="focused.settings.require
on="'global.yes' | translate"
>
msgid "global.no"
msgstr ""
msgid "global.yes"
msgstr ""
Is there a problem with multiple translated attributes in one element?
Everything works correctly with html file.
I try to extract text from simple js file and it doesn't work.
For example:
var exampleString = "<div translate>Not working</div>";
Currently, the file references for a POT entry are absolute, e.g. /home/gabe/foo/src/partial.html
. But that causes a lot of churn when the POT is checked into version control, since everyone's paths are different.
In all my client code, including the tests cases, I manually make the file references relative to the directory the POT file is written to. That won't work in gulp because the plugin doesn't know where you will output the POT file (that's handled later in the pipeline by gulp.dest
). But we could make it relative to file.base
or file.cwd
which is almost always the root of the project.
I have following header set yet it's not recognised by angular-gettext.
msgid ""
msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: POEditor.com\n"
"Project-Id-Version: app\n"
"Language: da\n"
The language is Danish.
I'm using gulp-angular-gettext to compile and extract. It might be a gulp-angular-gettext problem, but i'm not sure.
I catch the error when I launch gulp pot
node_modules/gulp-angular-gettext/node_modules/angular-gettext-tools/node_modules/esprima/esprima.js:3793
throw e;
^
Error: Line 18: Unexpected token >
Any idea, my code is similar to exemple given.
Maybe it would be better to have {format: 'json'}
as the default options object for compile
function.
As you have said @gabegorelick in #13, it's really more efficient and natural in gulp environment to use this format as default instead of javascript
.
Hi,
Your example produces 1 js / po.
How could I output a single "translations.js" file like with grunt-ng-gettext? I know I could use gulp-concat, but this results in having one angular.module() loading for each file, which is not optimized...
Thanks
In this example, you can compile all translations into one JavaScript file that looks like this:
angular.module('gettext').run(['gettextCatalog', function (gettextCatalog) {
/* jshint -W100 */
gettextCatalog.setStrings('uk', {/* strings */});
/* jshint +W100 */
}]);
How to compile the same file using gulp-angular-gettext ?
I'm migrating from angular-gettext from grunt to gulp. I can't find a way using this gulp plugin to compile to a single file for every languages *.po
files.
Here's my grunt configuration that creates a single file app/scripts/translations.js
nggettext_compile: {
all: {
options: {
module: 'ttpApp'
},
files: {
'app/scripts/translations.js': ['po/*.po']
}
}
},
Maybe an [out] option could be implemented, like for extract task ?
When running in one-pot-per-input-file mode, strings from input file A also appear in pot file B.
Example:
if..
then..
Hi,
I've tried to install gul-angular-gettext to my project. But when i wrote
var gettext = require('gulp-angular-gettext');
in my gulpfile.js, i've got this error.
I use nodejs 4.4.5...
maybe i'm blind, but how can i set default header, e.g. Project-Id-Version or Langauge to the created po file?
The $.gettext.extract task is unable to populate the strings on the template.pot file, for the following html code.
<b>{{ checkVar ? ('when_checkVar_true' | translate) : ('when_checkVar_false' | translate) }}</b>
Hi, I would like to see JADE parsing support.
Thank you.
Hello,
I may have missed something but how do you handle iterative worflow ?
Is there a way to generate POT files while keeping already existing keys from a given PO file ?
Each time I generate a pot file, I have a blank file so I need to manually merge my existing po file with that new one which is painfull :(
When compile format: 'javascript'
is set, the extension should be .js
instead of .json
.
I have may be missed something, but I have just copy/paste the example.
gulp.task('pot', function () {
return gulp.src(['static/admin/partials/*.html'])
.pipe(gettext.extract())
.pipe(gulp.dest('po'));
});
gulp.task('translations', function () {
return gulp.src('po/**/*.po')
.pipe(gettext.compile({
format: 'json'
}))
.pipe(gulp.dest('static/admin/translations'));
});
gulp pot -> create one pot file per sources. It should create one pot file:
$ ls po/
edit.html messages.html nmd_immo.html share.html
maps.html nmd_dne.html nmd_projets.html
Is this a bug ?
$ more po/edit.html
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: /Users/toutpt/makina/nmd/carteeco/mockup/static/admin/partials/edit.html
msgid "ACTIONS"
msgstr ""
...
Hi,
using the example config I have not been able to create any content in the target .pot file. The .pot file is more or less empty:
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Project-Id-Version: \n"
the test input in JADE looks like this:
h2(translate) hometranslation
p {{home.ctrlName}}
translate Test
input(type='text', placeholder="{{'Username' | translate}}")
any idea on this?
thanks
Hello,
I've something like this :
<option ng-selected="filter.selectedType === type.id" ng-repeat="type in filter.types" value="{{type.id}}">
{{type.name}}
</option>
How can I translate all items with you gulp task ?
I've try some like :
<option ng-selected="filter.selectedType === type.id" ng-repeat="type in filter.types" value="{{type.id}}" translate>
{{type.name}}
</option>
This format like this way :
+#: filter.html:53
+msgid "{{type.name | translate}}"
+msgstr ""
+
Thanks
Hi!
When installing gulp-angular-gettext one gets deprecated warnings.
npm WARN deprecated [email protected]: the module is now available as 'css-select'
It comes from angular-gettext-tools
which in turn comes from cheerio
.
So updating the dependencies should solve the problem.
Thank you!
The angular-gettext-tools team recently added TypeScript support for extraction. Is there any plan to update this gulp-angular-gettext to get these latest changes and support TypeScript as well?
The security fix on PR #45 broke the lodash.isstring
version. Latest version is 4.0.1, which doesn't constrain builds to lodash < 4.17.5 as far as I can tell. Would it make sense to depend on lodash
instead of lodash.isstring
given that angular-gettext-tools
and eslint
already depend on it?
If I pipe a vinyl stream that has no files into a gulp-angular-gettext extract
stream, I get the following error:
C:\Users\mbrunetti\Documents\mtdirect-next\packages\mtdirect-ui\node_modules\gulp-angular-gettext\lib\extract.js:74
cwd: firstFile.cwd,
^
TypeError: Cannot read property 'cwd' of null
at DestroyableTransform.flush [as _flush] (C:\Users\mbrunetti\Documents\mtdirect-next\packages\mtdirect-ui\node_modules\gulp-angular-gettext\lib\extract.js:74:21)
.....
It seems like the flush
function expects that firstFile
has been set, although it may not have been.
In the js file I have the following code
var buttonToRender = '<b translate>string_to_translate</b>';
when I run the $.gettext.extract function the template file does not contains the string_to_translate.
Any help is much appreciated.
I noticed that the output of the gulp and grunts tasks differ.
This bit me while reading the tutorial on the angular-gettext website, as it states: Be sure to add this file (in this case src/js/translations.js) to your project.
Grunt outputs additional angular code.
Grunt outputs the translations as Array(2)
(or two parameters).
Wheres Gulp outputs JSON
.
Grunt
angular.module('gettext').run(['gettextCatalog', function (gettextCatalog) {
/* jshint -W100 */
gettextCatalog.setStrings('nl', {"Active":"Actief","All":"Alle","Clear completed ({{completedCount}})":"Wis afgewerkte taken ({{completedCount}})","Completed":"Afgewerkt","Double-click to edit a todo":"Dubbelklik om een todo te bewerken","Mark all as complete":"Markeer als afgewerkt","What needs to be done?":"Wat moet gedaan worden?","{{$count}} item left":["{{$count}} item te gaan","{{$count}} items te gaan"]});
/* jshint +W100 */
}]);
Gulp
{"nl":{"Active":"Actief","All":"Alle","Clear completed ({{completedCount}})":"Wis afgewerkte taken ({{completedCount}})","Completed":"Afgewerkt","Double-click to edit a todo":"Dubbelklik om een todo te bewerken","Mark all as complete":"Markeer als afgewerkt","What needs to be done?":"Wat moet gedaan worden?","{{$count}} item left":["{{$count}} item te gaan","{{$count}} items te gaan"]}}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.