Socket
Socket
Sign inDemoInstall

@spinajs/intl

Package Overview
Dependencies
Maintainers
1
Versions
230
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spinajs/intl - npm Package Compare versions

Comparing version 2.0.19 to 2.0.38

9

lib/index.d.ts

@@ -103,1 +103,10 @@ import { AsyncModule } from '@spinajs/di';

}
/**
* Helper function for translations ( eg. for use as in template rentering engines)
*/
export declare function __translate(lang: string): (text: string | IPhraseWithOptions, ...args: any[]) => string;
export declare function __translateNumber(lang: string): (text: string | IPhraseWithOptions, count: number) => string;
export declare function __translateL(text: string): string[];
export declare function __translateH(text: string): any[];
export declare function guessLanguage(lang?: string): string;
export declare function defaultLanguage(): string;

66

lib/index.js

@@ -38,3 +38,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.SpineJsInternationalizationFromJson = exports.Intl = void 0;
exports.defaultLanguage = exports.guessLanguage = exports.__translateH = exports.__translateL = exports.__translateNumber = exports.__translate = exports.SpineJsInternationalizationFromJson = exports.Intl = void 0;
const node_async_hooks_1 = require("node:async_hooks");
const di_1 = require("@spinajs/di");

@@ -275,2 +276,65 @@ const configuration_1 = require("@spinajs/configuration");

};
/**
* Helper function for translations ( eg. for use as in template rentering engines)
*/
function __translate(lang) {
return (text, ...args) => {
const intl = di_1.DI.get(Intl);
if (typeof text === 'string') {
return intl.__({
phrase: text,
locale: lang,
}, ...args);
}
return intl.__(text, ...args);
};
}
exports.__translate = __translate;
function __translateNumber(lang) {
return (text, count) => {
const intl = di_1.DI.get(Intl);
if (typeof text === 'string') {
return intl.__n({
phrase: text,
locale: lang,
}, count);
}
return intl.__n(text, count);
};
}
exports.__translateNumber = __translateNumber;
function __translateL(text) {
const intl = di_1.DI.get(Intl);
return intl.__l(text);
}
exports.__translateL = __translateL;
function __translateH(text) {
const intl = di_1.DI.get(Intl);
return intl.__h(text);
}
exports.__translateH = __translateH;
function guessLanguage(lang) {
let selectedLang = lang;
if (!selectedLang) {
const store = di_1.DI.get(node_async_hooks_1.AsyncLocalStorage);
if (store) {
const storage = di_1.DI.get(node_async_hooks_1.AsyncLocalStorage).getStore();
if (!storage || !storage.language) {
selectedLang = di_1.DI.get(configuration_1.Configuration).get('intl.defaultLocale');
}
else {
selectedLang = storage.language;
}
}
else {
selectedLang = di_1.DI.get(configuration_1.Configuration).get('intl.defaultLocale');
}
}
return selectedLang;
}
exports.guessLanguage = guessLanguage;
function defaultLanguage() {
return di_1.DI.get(configuration_1.Configuration).get('intl.defaultLocale');
}
exports.defaultLanguage = defaultLanguage;
//# sourceMappingURL=index.js.map

12

package.json
{
"name": "@spinajs/intl",
"version": "2.0.19",
"version": "2.0.38",
"description": "internationalization for spinajs framework",

@@ -41,7 +41,7 @@ "main": "lib/index.js",

"dependencies": {
"@spinajs/configuration": "^2.0.19",
"@spinajs/di": "^2.0.19",
"@spinajs/configuration": "^2.0.38",
"@spinajs/di": "^2.0.38",
"@spinajs/exceptions": "^2.0.12",
"@spinajs/log": "^2.0.19",
"@spinajs/reflection": "^2.0.19",
"@spinajs/log": "^2.0.38",
"@spinajs/reflection": "^2.0.38",
"glob": "^7.1.6",

@@ -52,3 +52,3 @@ "lodash": "^4.17.15",

},
"gitHead": "51e801176ecec955cbf1eb2d91e9f4740cb2b471"
"gitHead": "5ea5440ee9db49595f531592ebdbc6d69f457082"
}

Sorry, the diff of this file is not supported yet

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