Comments (5)
Please try using -e
flag (the experimental AST Service parser). I'm considering making it the default.
from ngx-translate-extract.
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.
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.
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.
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)
- Array value erased when extract
- Extraneous path dependency?
- Angular 13 issue HOT 51
- Extract Parser error with Array.map & join
- Key 'constructor' is not parsed HOT 1
- Translations are not extracted from object in html template
- Not working with already interpolated strings and translateParams directive
- Dynamic string in translate instant
- Translation when using <ng-content>
- Allow translation files as inputs to prevent duplicate keys in an Angular workspace
- No updates in almost a year. Is this project dead? HOT 3
- my steps and how solve my error HOT 1
- Found 0 strings. HOT 1
- Getting Error while generating extracts- Ng Version -14.0.1 HOT 5
- [Question] Can we have html tags in translation strings? HOT 1
- Labels in html files preceded by variable are not found
- How can you sort by only adding new line at the bottom
- Is there a way to extract the default values from pipes
- Error generating with Angular 16 HOT 1
- Key in angular 17 new control flow get cleaned HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-translate-extract.