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 1.8.0 to 1.9.0-alpha.0

package-lock.json

15

.eslintrc.js
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
// disable the rule for all files
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
},
'@ribajs',
]
};

@@ -16,7 +16,3 @@ module.exports = {

"plugins": [
[
"@babel/plugin-transform-runtime", {
"corejs": 3
}
],
"@babel/plugin-syntax-export-default-from",

@@ -23,0 +19,0 @@ "@babel/plugin-proposal-class-properties",

{
"name": "@ribajs/i18n",
"description": "Internationalization module for Riba.js",
"version": "1.8.0",
"version": "1.9.0-alpha.0",
"author": "Pascal Garber <pascal@artandcode.studio>",

@@ -23,26 +23,29 @@ "url": "https://github.com/ribajs/riba/tree/master/packages/i18n",

"scripts": {
"type-check": "eslint src --ext .js,.jsx,.ts,.tsx --fix && tsc --noEmit",
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix && tsc --noEmit",
"build": "npm run build:module",
"build:module": "tsc",
"packages:link": "npm link @ribajs/core"
"packages:npm:link": "npm link @ribajs/core"
},
"devDependencies": {
"@babel/cli": "^7.7.7",
"@babel/core": "^7.7.7",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-proposal-object-rest-spread": "^7.7.7",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.7",
"@babel/preset-typescript": "^7.7.7",
"@babel/runtime-corejs3": "^7.7.7",
"babel-loader": "^8.0.6",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-object-rest-spread": "^7.9.5",
"@babel/preset-env": "^7.9.5",
"@babel/preset-typescript": "^7.9.0",
"@babel/runtime-corejs3": "^7.9.2",
"@ribajs/eslint-config": "1.9.0-alpha.0",
"@ribajs/tsconfig": "1.9.0-alpha.0",
"@ribajs/webpack-config": "0.0.1",
"babel-loader": "^8.1.0",
"babel-plugin-array-includes": "^2.0.3",
"core-js": "^3.6.2",
"core-js": "^3.6.5",
"eslint": "^6.8.0",
"typescript": "^3.7.4",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
"typescript": "^3.8.3",
"webpack": "^5.0.0-beta.15",
"webpack-cli": "^3.3.11"
},
"dependencies": {
"@ribajs/core": "^1.8.0"
"@ribajs/bs4": "1.9.0-alpha.0",
"@ribajs/core": "1.9.0-alpha.0"
},

@@ -55,2 +58,2 @@ "bugs": {

}
}
}

@@ -1,2 +0,3 @@

import { Utils, Binder, BinderWrapper } from '@ribajs/core';
import { Binder, BinderWrapper } from '@ribajs/core';
import { concat } from '@ribajs/utils/src/type';
import { ALocalesService } from '../../services/locales-base.service';

@@ -65,3 +66,3 @@

const newVars = this.customData.i18n.parseTemplateVars(_el);
this.customData.vars = Utils.concat(true, this.customData.vars, newVars);
this.customData.vars = concat(true, this.customData.vars, newVars);
// if (Object.keys(this.customData.vars).length) {

@@ -73,3 +74,3 @@ // console.warn('parsed templates vars', this.customData.vars);

// Vanilla works better than jquery data function?
this.customData.vars = Utils.concat(true, this.customData.vars, _el.dataset);
this.customData.vars = concat(true, this.customData.vars, _el.dataset);
// if (Object.keys(this.customData.vars).length) {

@@ -138,3 +139,3 @@ // console.warn('parsed attribute vars', this.customData.vars);

// console.warn('binder-changed newVar', newVar);
this.customData.vars = Utils.concat(true, this.customData.vars, newVar);
this.customData.vars = concat(true, this.customData.vars, newVar);
this.customData.translate();

@@ -141,0 +142,0 @@ }

@@ -1,13 +0,9 @@

import {
Component,
Binder,
View,
} from '@ribajs/core';
import { Langcode } from '../../interfaces';
import { ALocalesService } from '../../services/locales-base.service';
import { Component, View } from "@ribajs/core";
import { Langcode } from "../../interfaces";
import { ALocalesService } from "../../services/locales-base.service";
export interface Scope {
langcodes: Langcode[];
switch: AI18nSwitcherComponent['switch'];
toggle: AI18nSwitcherComponent['toggle'];
switch: AI18nSwitcherComponent["switch"];
toggle: AI18nSwitcherComponent["toggle"];
ready: boolean;

@@ -17,10 +13,9 @@ }

export abstract class AI18nSwitcherComponent extends Component {
protected abstract localesService: ALocalesService;
protected scope = {
langcodes: <Langcode[]> [],
langcodes: [] as Langcode[],
switch: this.switch,
toggle: this.toggle,
ready: <boolean> false,
ready: false,
};

@@ -37,3 +32,3 @@

*/
public switch(langcode: Langcode, context?: Binder<any>, event?: Event) {
public switch(langcode: Langcode, event?: Event) {
if (event) {

@@ -53,3 +48,3 @@ event.preventDefault();

*/
public toggle(context?: Binder<any>, event?: Event) {
public toggle(event?: Event) {
if (event) {

@@ -60,3 +55,3 @@ event.preventDefault();

for (const i in this.scope.langcodes) {
if (this.scope.langcodes.hasOwnProperty(i)) {
if (Object.prototype.hasOwnProperty.call(this.scope.langcodes, i)) {
if (this.scope.langcodes[i].active !== true) {

@@ -74,4 +69,3 @@ this.setLangcode(this.scope.langcodes[i].code);

if (langcode) {
return this.initLocales(langcode)
.then((langcodes) => {
return this.initLocales(langcode).then(() => {
return super.init(observedAttributes);

@@ -81,12 +75,13 @@ });

}
return new Promise<View | null | undefined>((resolve, reject) => {
this.localesService.event.on('ready', (langcode: string, translationNeeded: boolean) => {
this.initLocales(langcode)
.then((langcodes) => {
super.init(observedAttributes)
.then((view) => {
resolve(view);
return new Promise<View | null | undefined>((resolve) => {
this.localesService.event.on(
"ready",
(langcode: string, translationNeeded: boolean) => {
this.initLocales(langcode).then((langcodes) => {
super.init(observedAttributes).then((view) => {
resolve(view);
});
});
});
});
}
);
});

@@ -97,24 +92,28 @@ }

// set avaible langcodes
return this.localesService.getAvailableLangcodes()
.then((langcodes) => {
this.scope.langcodes = langcodes;
// set active langcodes
this.scope.langcodes.forEach((langCode) => {
langCode.active = (langCode.code === langcode);
});
return this.scope.langcodes;
})
.then((langcodes) => {
this.localesService.event.on('changed', (changedLangcode: string, initial: boolean) => {
// Activate localcode and disable the other
return this.localesService
.getAvailableLangcodes()
.then((langcodes) => {
this.scope.langcodes = langcodes;
// set active langcodes
this.scope.langcodes.forEach((langCode) => {
langCode.active = (langCode.code === changedLangcode);
langCode.active = langCode.code === langcode;
});
return this.scope.langcodes;
})
.then((langcodes) => {
this.localesService.event.on(
"changed",
(changedLangcode: string, initial: boolean) => {
// Activate localcode and disable the other
this.scope.langcodes.forEach((langCode) => {
langCode.active = langCode.code === changedLangcode;
});
}
);
return langcodes;
})
.then((langcodes) => {
this.scope.ready = true;
return langcodes;
});
return langcodes;
})
.then((langcodes) => {
this.scope.ready = true;
return langcodes;
});
}

@@ -121,0 +120,0 @@

@@ -1,10 +0,12 @@

export { AI18nSwitcherComponent } from './abstract-switcher/switcher.abstract.component';
import { i18nSwitcherComponentWrapper } from './switcher/switcher.component';
import { ALocalesService } from '../services/locales-base.service';
import { Components } from '@ribajs/core';
export { AI18nSwitcherComponent } from "./abstract-switcher/switcher.abstract.component";
import { i18nSwitcherComponentWrapper } from "./switcher/switcher.component";
import { i18nShareComponentWrapper } from "./share/share.component";
import { ALocalesService } from "../services/locales-base.service";
import { Components } from "@ribajs/core";
export default (localesService: ALocalesService): Components => {
return {
i18nSwitcherComponent: i18nSwitcherComponentWrapper(localesService),
I18nSwitcherComponent: i18nSwitcherComponentWrapper(localesService),
I18nShareComponent: i18nShareComponentWrapper(localesService),
};
};

@@ -1,11 +0,13 @@

import { Binder, TypeOfComponent } from '@ribajs/core';
import { AI18nSwitcherComponent } from '../abstract-switcher/switcher.abstract.component';
import { Langcode } from '../../interfaces';
import { ALocalesService } from '../../services/locales-base.service';
import { TypeOfComponent } from "@ribajs/core";
import { AI18nSwitcherComponent } from "../abstract-switcher/switcher.abstract.component";
import { Langcode } from "../../interfaces";
import { ALocalesService } from "../../services/locales-base.service";
export const i18nSwitcherComponentWrapper = (localesService: ALocalesService): TypeOfComponent<AI18nSwitcherComponent> => {
export const i18nSwitcherComponentWrapper = (
localesService: ALocalesService
): TypeOfComponent<AI18nSwitcherComponent> => {
return class I18nSwitcherComponent extends AI18nSwitcherComponent {
public static tagName = "i18n-switcher";
public static tagName: string = 'i18n-switcher';
public _debug = false;

@@ -19,6 +21,6 @@ static get observedAttributes() {

protected scope = {
langcodes: <Langcode[]> [],
langcodes: [] as Langcode[],
switch: this.switch,
toggle: this.toggle,
ready: <boolean> false,
ready: false,
};

@@ -36,4 +38,5 @@

*/
public switch(langcode: Langcode, context?: Binder<any>, event?: Event) {
return super.switch(langcode, context, event);
public switch(langcode: Langcode, event?: Event) {
this.debug("switch", langcode);
return super.switch(langcode, event);
}

@@ -46,4 +49,4 @@

*/
public toggle(context?: Binder<any>, event?: Event) {
return super.toggle(context, event);
public toggle(event?: Event) {
return super.toggle(event);
}

@@ -50,0 +53,0 @@

@@ -1,3 +0,1 @@

import { RibaModule } from '@ribajs/core';
export * from './binders';

@@ -8,17 +6,2 @@ export * from './components';

export * from './services';
import bindersWrapper from './binders';
import formattersWrapper from './formatters';
import componentsWrapper from './components';
import * as services from './services';
export const i18nModule = (localesService: services.ALocalesService): RibaModule => {
return {
binders: bindersWrapper(localesService),
components: componentsWrapper(localesService),
formatters: formattersWrapper(localesService),
services,
};
};
export default i18nModule;
export * from './i18n.module';

@@ -1,2 +0,3 @@

import { Utils, EventDispatcher } from '@ribajs/core';
import { EventDispatcher } from '@ribajs/core';
import { clone } from '@ribajs/utils/src/type';
import { Langcode, LocalPluralization, LocalVar } from '../interfaces';

@@ -45,3 +46,3 @@

if (properties && properties.length) {
let local: any = Utils.clone(true, locals);
let local: any = clone(true, locals);
for (const property of properties) {

@@ -48,0 +49,0 @@ if (!property) {

{
"extends": "@ribajs/tsconfig",
"files": [
"src/ts/index.ts"
],
"compilerOptions": {
"module": "commonjs",
"target": "esnext",
"lib": ["es7", "dom"],
"moduleResolution": "node",
"typeRoots": ["./node_modules/@types", "./node_modules/@ribajs/core/src/types"],
"outDir": "dist",
"declaration": true,
"inlineSourceMap": true,
"noUnusedLocals": true,
"esModuleInterop": true,
"strict": true,
"noImplicitAny": true,
"noImplicitThis": true,
"allowSyntheticDefaultImports": true
},
"include": ["src"],
"exclude": ["**/*.spec.ts"],
"typeRoots": ["./node_modules/@types", "./src/ts/types", "./node_modules/@ribajs/core/src/types"]
}
}
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