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

@translation/angular

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@translation/angular - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

10

CHANGELOG.md
# 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 @@

9

package.json
{
"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 = `&lt;${number}&gt;`
} else if (HtmlTagExtraction.isClosingTag(extraction)) { // </tag>
} else if (HtmlTagExtraction.isClosingTag(extraction)) { // </tag>
number = HtmlTagExtraction.removeFromStackAndGetNumber(extraction)
substitution = `&lt;/${number}&gt;`
} else if (HtmlTagExtraction.isSelfClosingTag(extraction)) { // <tag/>
} else if (HtmlTagExtraction.isSelfClosingTag(extraction)) { // <tag/>
number = HtmlTagExtraction.addToStackAndGetNumber(extraction)
substitution = `&lt;${number}/&gt;`
} 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))

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