@taskworld/typescript-custom-transformer-l10n
Advanced tools
Comparing version 1.0.0 to 2.0.0
{ | ||
"devDependencies": { | ||
"jest": "^24.8.0", | ||
"prettier": "^1.17.1", | ||
"typescript": "^3.2.2" | ||
@@ -10,3 +11,3 @@ }, | ||
"name": "@taskworld/typescript-custom-transformer-l10n", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "A TypeScript Custom AST transformer that inlines localization strings into the source code", | ||
@@ -13,0 +14,0 @@ "main": "transformer.js", |
@@ -48,14 +48,16 @@ # @taskworld/typescript-custom-transformer-l10n | ||
<h1> | ||
{__({ | ||
$key: 'tutorial.welcome.headline', | ||
en: 'Welcome to %{workspace_name}', | ||
th: 'ยินดีต้อนรับเข้าสู่ %{workspace_name}', | ||
})} | ||
{__( | ||
__.$('tutorial.welcome.headline', { | ||
en: 'Welcome to %{workspace_name}', | ||
th: 'ยินดีต้อนรับเข้าสู่ %{workspace_name}', | ||
}) | ||
)} | ||
</h1> | ||
<p> | ||
{__({ | ||
$key: 'tutorial.welcome.paragraph', | ||
en: 'Your team will have all that you need to get work done.', | ||
th: 'บริหารจัดการงานได้อย่างครบถ้วนและมีประสิทธิภาพ', | ||
})} | ||
{__( | ||
__.$('tutorial.welcome.paragraph', { | ||
en: 'Your team will have all that you need to get work done.', | ||
th: 'บริหารจัดการงานได้อย่างครบถ้วนและมีประสิทธิภาพ', | ||
}) | ||
)} | ||
</p> | ||
@@ -68,1 +70,3 @@ </section> | ||
See the article [How to Write a TypeScript Transform (Plugin)](https://dev.doctorevidence.com/how-to-write-a-typescript-transform-plugin-fc5308fdd943) for how to use it in, e.g., webpack. | ||
**Important:** If you use build caching, e.g. `cache-loader`, make sure to set it up so that changes to the localization data would invalidate the cached build output. |
@@ -66,5 +66,3 @@ const ts = require('typescript') | ||
} | ||
const properties = [ | ||
ts.createPropertyAssignment('$key', ts.createLiteral(arg.text)), | ||
] | ||
const properties = [] | ||
for (const language of Object.keys(options.l10nData)) { | ||
@@ -80,3 +78,7 @@ const foundText = options.l10nData[language][arg.text] | ||
} | ||
return ts.createObjectLiteral(properties) | ||
return ts.createCall( | ||
ts.createPropertyAccess(ts.createIdentifier('__'), '$'), | ||
[], | ||
[arg, ts.createObjectLiteral(properties)] | ||
) | ||
} else { | ||
@@ -83,0 +85,0 @@ return arg |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6177
89
71
3