-
Notifications
You must be signed in to change notification settings - Fork 0
Is there any simple steps that I can follow in order to use this? #2
Comments
I'll update the README.md today w/ more instructions. But in short if you use webpack & ts-loader you can specify it as part of the config (https://github.com/TypeStrong/ts-loader#getcustomtransformers-----before-transformerfactory-after-transformerfactory---). If you use |
I am new to typescript world and couldn't find the document how to use this ts-transform-react-intl. |
unfortunately you'd need to a custom compiler wrapper like the one linked above and some knowledge of TypeScript to use this. TS doesn't support custom transformers officially |
Apparently, ts-loader supports custom transformes using Can someone with more experience add examples for those please? |
Could it be as simple as this (with const intl = require('ts-transform-react-intl');
module.exports = {
module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
options: {
getCustomTransformers: () => ({
before: [
intl.transform({
idPrefix: "prefix",
onMsgExtracted: intl.aggregate(msgs),
}),
]
})
}
}
],
}
} |
@Kronuz PR's welcome :) |
@longlho, what is the |
it's the prefix for all message ids. This is basically namespacing. By default it uses the package name from package.json. e.g: If you run this on a project called |
@Kronuz Where is the |
That’s simply an empty object of type |
@Kronuz ah okay. Have you been successful in writing that object to a JSON file? Looking for examples, if you have any. I’m using webpack and ts-loader as well |
I haven’t tried... you just need to make a small webpack plugin which writes the object after everything has been processed. |
Hi,
I am new to typescript world and couldn't find the document how to use this ts-transform-react-intl. Do you have any simple steps? It would be really helpful.
I couldn't find the way to add plugin to typescript like babel. I guess I need to implement my own version of compiler to complete the generate translation. Please help.
Thanks,
The text was updated successfully, but these errors were encountered: