Comments (2)
Hmm, sorry to hear that. I was not aware that esprima - what we now use to parse .js files - does not support TypeScript.
Right now, we don't really have the resources to implement this - so you probably need to stay on 2.x for now.
However, we'd love to accept a PR for that! Feel free to ask if you need any guidance. Roughly speaking, this is what would need to be done:
- Create a new file
lib/utils/commands/utils/parse-ts.js
based on https://github.com/Cropster/ember-l10n/blob/master/lib/commands/utils/parse-js.js - Look for a good TS AST parser - basically an equivalent to http://esprima.org/. Replace the esprima logic from
parse-js
with the AST logic of the TS parser. - In the file
/lib/commands/extract.js
, adapt the method_extractFromJS()
to callparseJsFile()
only on files ending with.js
, and call the newparseTsFile()
afterwards for files ending with.ts
. You can uselet jsFiles = this._getFiles(options, 'js');
andlet tsFiles = this._getFiles(options, 'ts');
to get the appropriate files.
The whole method would look something like this:
_extractFromJS(options) {
let jsFiles = this._getFiles(options, 'js');
let tsFiles = this._getFiles(options, 'ts');
let outputFile = this.potFile;
let potFile = this._getFileName(outputFile);
jsFiles.forEach(file => {
if (this._shouldSkipFile(file)) {
this.ui.writeLine(chalk.yellow(`Skipping ${file}...`));
return;
}
this.ui.writeLine(chalk.white(`Extracting ${file} >>> ${potFile}...`));
parseJsFile(file, options, this.messageGettextItems);
});
tsFiles.forEach(file => {
if (this._shouldSkipFile(file)) {
this.ui.writeLine(chalk.yellow(`Skipping ${file}...`));
return;
}
this.ui.writeLine(chalk.white(`Extracting ${file} >>> ${potFile}...`));
parseTsFile(file, options, this.messageGettextItems);
});
this.ui.writeLine(chalk.green.bold(`\nExtracted ${files.length} files ✔`));
},
from ember-l10n.
This has been fixed in 3.2.0, which now uses a different parser which also allows to parse ts files! I haven't tried this in a production app, but there is a test that covers that. Please let us know if you encounter any issues.
from ember-l10n.
Related Issues (20)
- Add node tests for CLI functionality HOT 1
- Validate translations
- Validation seems to be buggy HOT 1
- Remove excluded.pot functionality HOT 1
- Remove comments from generated JSON files
- Ensure quotes are not changed
- Use ember-fetch instead of ember-ajax for fetching locale files HOT 1
- Add changes command
- Does not work with fastboot HOT 3
- tVar usage? HOT 1
- Sync command doesn't seems to work HOT 1
- Error while extracting: duplicate message definition HOT 4
- Add override option to ignore extract error HOT 2
- Upgrade to shelljs 0.8.4
- Question HOT 5
- Extract command is not picking up new strings.
- Build problems after updating ember-l10n from 4.x to 5.x HOT 7
- Some strings are not extracted even after upgrading to 5.2.0 HOT 6
- Investigate alternatives to eval HOT 3
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 ember-l10n.