els-intl-addon
Advanced tools
Comparing version 1.0.0 to 1.0.1
24
index.js
@@ -6,8 +6,17 @@ const flat = require("flat"); | ||
function isLocalizationHelperTranslataionName(focusPath) { | ||
return ( | ||
function isLocalizationHelperTranslataionName(focusPath, type) { | ||
let p = focusPath.parent; | ||
if (!p) { | ||
return false; | ||
} | ||
if (type === "script" && focusPath.node.type === "StringLiteral") { | ||
let isMemberExp = p.type === 'CallExpression' && p.callee && p.callee.type === "MemberExpression"; | ||
let hasValidCallee = isMemberExp && p.callee.property && p.callee.property.type === 'Identifier' && p.callee.property.name === "t"; | ||
return hasValidCallee && p.arguments.indexOf(focusPath.node) === 0; | ||
} | ||
return type === "template" && ( | ||
focusPath.node.type === "StringLiteral" && | ||
(focusPath.parent.type === "MustacheStatement" || | ||
focusPath.parent.type === "SubExpression") && | ||
focusPath.parent.path.original === "t" | ||
(p.type === "MustacheStatement" || | ||
p.type === "SubExpression") && | ||
p.path.original === "t" | ||
); | ||
@@ -90,6 +99,3 @@ } | ||
) { | ||
if (type !== "template") { | ||
return results; | ||
} | ||
if (isLocalizationHelperTranslataionName(focusPath)) { | ||
if (isLocalizationHelperTranslataionName(focusPath, type)) { | ||
const items = getTranslations(_); | ||
@@ -96,0 +102,0 @@ const val = focusPath.node.value.indexOf("ELSCompletionDummy"); |
{ | ||
"name": "els-intl-addon", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Ember Language Server intl extension", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,3 +6,4 @@ # els-intl-addon | ||
Install this addon as `dev-dependency` inside your ember project. | ||
Install this addon as `dev-dependency` inside your ember project | ||
or download it and specify addon path in UELS settings. | ||
@@ -22,2 +23,12 @@ ### NPM | ||
## Usage | ||
Try autocomplete for `{{t 'tanslation..'}}` inside templates. | ||
Try autocomplete for `{{t 'tanslation..'}}` inside templates. | ||
Try autocompleta for `this.intl.t("translation..')` inside scripts. | ||
* You can write translation result and it will be replaced to path. | ||
```js | ||
'some.translation.path': 'Translation result' | ||
``` | ||
```hbs | ||
{{t 'Translati..'}} -> {{t 'some.translation.path'}} | ||
``` |
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
7372
148
33