Git Product home page Git Product logo

Comments (5)

biesbjerg avatar biesbjerg commented on July 30, 2024

Please try using -e flag (the experimental AST Service parser). I'm considering making it the default.

from ngx-translate-extract.

FelixWessendorf avatar FelixWessendorf commented on July 30, 2024

Thanks for your reply. I've tried the AST parser - without any luck. It's giving me

INFO: Extracting strings from 'src\app' ERROR: TypeError: Cannot read property 'parameters' of undefined error Command failed with exit code 1.

Maybe with any luck, I will have time to figure out what's going on there. Sticking to the default parser till that happens. In order to have that work, you need to make sure the call to the translation service is the very last statement in a single line of code that uses literal strings.

from ngx-translate-extract.

biesbjerg avatar biesbjerg commented on July 30, 2024

That error should be fixed in release 1.0.0. It happened in older versions of file did not have a constructor. Can you the newest release a try? (Package name changed to @biesbjerg/ngx-translate-extract)

from ngx-translate-extract.

FelixWessendorf avatar FelixWessendorf commented on July 30, 2024

Thanks for the hint. I switched to the newest release (which I didn't know existed before you mentioned it). And it's all working now with the AST parser. Good work! It should have a bunch of unit tests and if they are okay you should definiteley make the AST parser default.

The regexp in the service parser still is to greedy. You can fix that with a question mark at the right place (behind [^\1\r\n]*) which makes reading the string non greedy like: /(?:get|instant)\s*\(\s*(\[?\s*(['"`])([^\1\r\n]*?)\2\s*\]?)/. But still.... you won't parse strings with correctly esacaped single quotes like this.translate.instant('Welcome to Chicago O\'Hare').

It is very difficult to get a good regexp for all sorts of appearances working - AST is the more natural, easier and safer way of searching for the translatable strings.

from ngx-translate-extract.

biesbjerg avatar biesbjerg commented on July 30, 2024

Yeah, unfortunately making the regex non-greedy breaks a bunch of tests.

I think too, that AST is the way to go. I will probably release a v2.0 soon-ish, with AST as the default parser to get more feedback.

Using Angular's template parser to extract strings from templates would also be cool and less error prone, but it's pretty complicated stuff.

Closing this one, as I don't think it can be easily fixed by changing the regex and AST will be default in the near future.

from ngx-translate-extract.

Related Issues (20)

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.