@translation/angular
Advanced tools
Comparing version 1.3.0 to 1.4.0
# Changelog | ||
## [v1.4.0](https://github.com/translation/angular/releases/tag/v1.4.0) (2023-01-12) | ||
#### New features: | ||
* Handle placeholders (named or unnamed) in components ([#5](https://github.com/translation/angular/pull/5)). | ||
#### Fixes (bugs & defects): | ||
* Fix dependency issues. | ||
## [v1.3.0](https://github.com/translation/angular/releases/tag/v1.3.0) (2023-01-10) | ||
@@ -4,0 +14,0 @@ |
{ | ||
"name": "@translation/angular", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Translation.io client for Angular applications", | ||
@@ -57,10 +57,11 @@ "repository": { | ||
"license": "MIT", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"dependencies": { | ||
"axios": "^0 >=0.16", | ||
"fast-xml-parser": "^4", | ||
"https-proxy-agent": "^5", | ||
"jest": ">=23", | ||
"@formatjs/icu-messageformat-parser": "^2" | ||
}, | ||
"devDependencies": { | ||
"jest": ">=23" | ||
}, | ||
"scripts": { | ||
@@ -67,0 +68,0 @@ "test": "jest" |
@@ -54,22 +54,30 @@ const HtmlTagExtraction = require('./html-tag-extraction') | ||
if (extraction.includes('id="INTERPOLATION_') && !extraction.includes('equiv-text=')) { // {x2}, {x3}, ... | ||
if (extraction.includes('id="INTERPOLATION_') && ! extraction.includes('equiv-text=')) { // {x2}, {x3}, ... // Interpolations in HTML templates | ||
number = parseInt(extraction.split('id="INTERPOLATION_', 2)[1].split('"', 2)[0]) + 1 | ||
substitution = `{x${number}}` | ||
} else if(extraction.includes('id="INTERPOLATION"') && !extraction.includes('equiv-text=')) { // {x1} - May be converted later to {x} if only 1 | ||
} else if (extraction.includes('id="INTERPOLATION"') && ! extraction.includes('equiv-text=')) { // {x1} - May be converted later to {x} if only 1 | ||
substitution = `{x1}` | ||
} else if (extraction.includes('id="INTERPOLATION') && extraction.includes('equiv-text="{{') && extraction.includes('}}"')) { // {name}, {variable}, {count} | ||
} else if (this.includesAll(extraction, ['id="INTERPOLATION', 'equiv-text="{{', '}}"'])) { // {name}, {variable}, {count} | ||
name = extraction.split('equiv-text="{{', 2)[1].split('}}"', 2)[0].trim() | ||
substitution = `{${name}}` | ||
} else if (extraction.includes('id="ICU')) { // {icu1}, {icu2}, ... - May be converted later to {icu} if only 1 | ||
} else if (this.includesAll(extraction, ['id="PH_', 'equiv-text='])) { // {x2}, {x3}, ... // Interpolations (placeholders) in components, using $localize | ||
number = parseInt(extraction.split('id="PH_', 2)[1].split('"', 2)[0]) + 1 | ||
substitution = `{x${number}}` | ||
} else if (this.includesAll(extraction, ['id="PH"', 'equiv-text='])) { // {x1} - May be converted later to {x} if only 1 | ||
substitution = `{x1}` | ||
} else if (extraction.includes('id="ICU')) { // {icu1}, {icu2}, ... - May be converted later to {icu} if only 1 | ||
number = (existingSubstitutions.join(" ").match(/{icu\d+?}/g) || []).length + 1 | ||
substitution = `{icu${number}}` | ||
} else if (HtmlTagExtraction.isOpeningTag(extraction)) { // <tag> | ||
} else if (HtmlTagExtraction.isOpeningTag(extraction)) { // <tag> | ||
number = HtmlTagExtraction.addToStackAndGetNumber(extraction) | ||
substitution = `<${number}>` | ||
} else if (HtmlTagExtraction.isClosingTag(extraction)) { // </tag> | ||
} else if (HtmlTagExtraction.isClosingTag(extraction)) { // </tag> | ||
number = HtmlTagExtraction.removeFromStackAndGetNumber(extraction) | ||
substitution = `</${number}>` | ||
} else if (HtmlTagExtraction.isSelfClosingTag(extraction)) { // <tag/> | ||
} else if (HtmlTagExtraction.isSelfClosingTag(extraction)) { // <tag/> | ||
number = HtmlTagExtraction.addToStackAndGetNumber(extraction) | ||
substitution = `<${number}/>` | ||
} else if (extraction.includes('<x id="') && this.excludesAll(extraction, ['id="INTERPOLATION', 'id="PH', 'id="ICU'])) { // {name} // Named interpolations (placeholders) in components, using $localize, excluding specific ids, so that they end up as parsing errors below | ||
name = extraction.split('id="', 2)[1].split('"', 2)[0].trim() | ||
substitution = `{${name}}` | ||
} else { | ||
@@ -83,2 +91,22 @@ substitution = `{parsingError}`; | ||
// Helper method (because String.prototype.includes() does not accept an array of strings) | ||
static includesAll(extraction, terms) { | ||
for (const term of terms) { | ||
if (! extraction.includes(term)) { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
// Helper method (because String.prototype.excludes() doesn't exist and String.prototype.includes() does not accept an array of strings) | ||
static excludesAll(extraction, terms) { | ||
for (const term of terms) { | ||
if (extraction.includes(term)) { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
static renameKey(object, oldKey, newKey) { | ||
@@ -85,0 +113,0 @@ Object.defineProperty(object, newKey, Object.getOwnPropertyDescriptor(object, oldKey)) |
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
50744
1
702
4
+ Addedaxios@^0 >=0.16
+ Addedfast-xml-parser@^4
+ Addedhttps-proxy-agent@^5
+ Added@formatjs/ecma402-abstract@2.2.4(transitive)
+ Added@formatjs/fast-memoize@2.2.3(transitive)
+ Added@formatjs/icu-messageformat-parser@2.9.4(transitive)
+ Added@formatjs/icu-skeleton-parser@1.8.8(transitive)
+ Added@formatjs/intl-localematcher@0.5.8(transitive)
+ Addedagent-base@6.0.2(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@0.29.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedfast-xml-parser@4.5.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedhttps-proxy-agent@5.0.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedms@2.1.3(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
+ Addedstrnum@1.0.5(transitive)
+ Addedtslib@2.8.1(transitive)