Git Product home page Git Product logo

gulp-angular-translate-extract's People

Contributors

bcabanes avatar d42f avatar daghoidahl avatar maximeborges avatar mjonakcc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gulp-angular-translate-extract's Issues

Wrong pattern gets extracted when using complex translate-value-* attribute

When using a slightly more complex translate-value-* attribute, this plugin extracts wrong keys.

<p
    translate="page.something"
    translate-value-link="<a href=&quot;/terms&quot; target=&quot;_blank&quot;>{{ 'page.terms.title' | translate }}</a>"
    ></p>

From the HTML above, the following is extracted:

"{{ 'page": {
    "terms": {
        "title' | translate }}": ""
    }
}

But only the key page.terms.title should actually be extracted. This happens on version 0.1.8.

Support translate-attr-*

The translate directive supports translating attributes. E.g. placeholder="…" can be translated using translate-attr-placeholder="…". The extractor doesn't recognise this syntax.

HtmlDirective regex can't handle a greater than sign inside an expression

The HtmlDirective regex:
HtmlDirective: '<[^>]*translate[^{>]*>([^<]*)<\/[^>]*>',
doesn't handle a greater than sign if it's inside an expression on the html element. E.g.:
<span ng-if="something > 0" translate> translate.key </span>

I fixed it like this:
<(?:[^>]*?|(?:[^>]*?["].*?["][^>]*?))translate[^{>]*>([^<]*)<\/[^>]*>

I threw up inside my mouth a little while writing it. It should ignore anything inside quotes before the translate directive. Don't know if anyone can write something prettier?

output is placed off

the output directory i18nextract is getting created in ../../ - or oven somewhere further off.

can you make it work that the standard gulp.dest() works - e.g.

    .pipe(gulp.dest('testdirectory/js'));

the config option "dest" is imho not needed, since gulp.dest() takes this task.

Is { necessary in the HtmlDirective regex

The HtmlDirective regex looks like this: <[^>]*translate[^{>]*>([^<]*)<\/[^>]*>

This will not match when I use the translate-values directive before the translate directive, because of the { in the middle of the HtmlDirective regex:
<span translate translate-values="{'something':$ctrl.something}">translation.key</span>

An easy workaround is to put the translate directive after the translate-values directive:
<span translate-values="{'something':$ctrl.something}" translate>translation.key</span>

But I am wondering what the { in the HtmlDirective regex is even guarding against? Is it safe to remove? I see no changes when I remove it and run translate extract on the codebase I'm working on atm.

Html directive with interpolation doesn't work properly

In some cases I need to add the translation id as a model property and then use it with interpolation on a certain html tag.

The html directive should exclude this case:
<ANY translate="{{ model.someProperty }}"></ANY>

This actually generates the following:
"{{ model": { "someProperty }}": "{{ model.someProperty }}" }

Support for interpolateParams in $translate

The current regex expressions doesn't recognize any of the following syntax:

$translate('TRANSLATION', {param1: 'value', param2: 'value'});
$translate.instant('TRANSLATION', {param1: 'value', param2: 'value'});
$translate(['TRANSLATION', 'TRANSLATION_1'], {param1: 'value', param2: 'value'});

I was able to make it work by adding a wildcard .* right before the closing parenthesis. Some better checking should probably be done though.

JavascriptServiceSimpleQuote: '\\$translate\\(\\s*\'((?:\\\\.|[^\'\\\\])*)\'[^\\)]*.*\\)',
JavascriptServiceDoubleQuote: '\\$translate\\(\\s*"((?:\\\\.|[^"\\\\])*)"[^\\)]*.*\\)',
JavascriptServiceArraySimpleQuote: '\\$translate\\((?:\\s*(\\[\\s*(?:(?:\'(?:(?:\\.|[^.*\'\\\\])*)\')\\s*,*\\s*)+\\s*\\])\\s*).*\\)',
JavascriptServiceArrayDoubleQuote: '\\$translate\\((?:\\s*(\\[\\s*(?:(?:"(?:(?:\\.|[^.*\'\\\\])*)")\\s*,*\\s*)+\\s*\\])\\s*).*\\)',
JavascriptServiceInstantSimpleQuote: '\\$translate\\.instant\\(\\s*\'((?:\\\\.|[^\'\\\\])*)\'[^\\)]*.*\\)',
JavascriptServiceInstantDoubleQuote: '\\$translate\\.instant\\(\\s*"((?:\\\\.|[^"\\\\])*)"[^\\)]*.*\\)',

Can't understand how to select the destination directory

I do:

gulp.task "extract i18n", ->
  log "Generate i18n files " + (new Date()).toString()
  gulp.src ['public/build/js/app.js']
  .pipe angularTranslate
    lang: TR_lang
    dest: 'public/i18n'
  .pipe gulp.dest 'public/i18n'

since the file I want to scan is 'public/build/js/app.js'
And I get a directory at the root of my project called i18n/
If I rerun the task all my translations get removed.

I really don't understand how you use the destination parameter, so if anyone can help me that will be cool.

Translated strings in the json files are not preserved

I'm not sure if this is really an issue. My expectation was that gulp-angular-translate-extract preserves the translated strings in the json files. In other words: I'd like to use the following process:

  1. When I run gulp-angular-translate-extract the first time it creates the json files for all languages.
  2. Then I manually edit the json files to translate the extracted keys.
  3. When I've added more keys to my source files I run gulp-angular-translate-extract. Now I expect my translations to be still present and the new keys added empty.

Is that the way gulp-angular-translate-extract is intended to be used?

If yes, than this is a bug report ;-)

gulp-angular-translate-extract doesn't preserve my already translated strings. Everytime I run it a json file with only the keys present is created. The statistics say: en_US statistics: Updated: 0 / Deleted: 0 / New: 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.