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

@ribajs/i18n

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ribajs/i18n - npm Package Compare versions

Comparing version 0.18.4 to 0.18.5

4

package.json
{
"name": "@ribajs/i18n",
"description": "Internationalization extension for Riba.js",
"version": "0.18.4",
"version": "0.18.5",
"author": "Pascal Garber <pascal@jumplink.eu>",

@@ -59,2 +59,2 @@ "url": "https://github.com/ribajs/riba/tree/master/packages/i18n",

}
}
}

@@ -64,2 +64,5 @@ import { Utils, ITwoWayBinder, BinderWrapper, JQuery as $ } from '@ribajs/core';

this.customData.vars = Utils.concat(true, this.customData.vars, newVars);
if (Object.keys(this.customData.vars).length) {
this.customData.i18n.debug('parsed templates vars', this.customData.vars);
}

@@ -70,5 +73,11 @@ // parse data attributes to vars

this.customData.vars = Utils.concat(true, this.customData.vars, this.customData.$el.data());
if (Object.keys(this.customData.vars).length) {
this.customData.i18n.debug('parsed attribute vars', this.customData.vars);
}
// Parse templates wich have his own translations
this.customData.langVars = this.customData.i18n.parseLocalVars(this.customData.$el);
if (this.customData.langVars && Object.keys(this.customData.langVars).length) {
this.customData.i18n.debug('parsed own translations', this.customData.langVars);
}
};

@@ -94,5 +103,6 @@

if (!this.customData.properties) {
if (!this.customData.properties || this.customData.properties.length === 0) {
// get the default translation if available
if (this.customData.langVars && this.customData.langVars.default) {
this.customData.i18n.debug('Translate by default', this.customData.langVars.default);
return this.customData.applyTranslation(this.customData.langVars.default);

@@ -105,3 +115,4 @@ }

.then((local: string) => {
if (local) {
if (local && typeof(local) === 'string') {
// this.customData.i18n.debug('Translate by properties', [langcode, ...this.customData.properties], local);
return this.customData.applyTranslation(local);

@@ -111,2 +122,3 @@ }

if (this.customData.langVars && this.customData.langVars.default) {
this.customData.i18n.debug('Translate by default as fallback', this.customData.langVars.default);
return this.customData.applyTranslation(this.customData.langVars.default);

@@ -113,0 +125,0 @@ }

@@ -181,6 +181,7 @@ import { Utils, EventDispatcher, Debug } from '@ribajs/core';

public setTranslateStringVars(translateString: string, vars: ILocalVar) {
if (!translateString || typeof(translateString.match) !== 'function') {
if (!translateString || Object.keys(vars).length === 0 || typeof(translateString.match) !== 'function') {
return translateString;
}
const matches = translateString.match(/{{\s*?[A-Za-z_-]+\s*?}}/gm);
this.debug('setTranslateStringVars', translateString, vars);
const matches = translateString.match(/{{\s*?[A-Za-z0-9_-]+\s*?}}/gm);
if (matches) {

@@ -196,2 +197,3 @@ for (const match of matches) {

}
this.debug('setTranslateStringVars', translateString);
return translateString;

@@ -198,0 +200,0 @@ }

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