Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@taskworld/typescript-custom-transformer-l10n

Package Overview
Dependencies
Maintainers
5
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@taskworld/typescript-custom-transformer-l10n - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

3

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc