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

@coorpacademy/translate

Package Overview
Dependencies
Maintainers
27
Versions
271
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coorpacademy/translate - npm Package Compare versions

Comparing version 6.1.5 to 6.1.6-alpha.340

16

es/test/translate.js

@@ -31,2 +31,10 @@ import test from 'ava';

});
test('should accept nested value', t => {
const translate = createTranslate({
foo: {
foo_none: 'I have no apples'
}
});
t.is(translate('foo.foo_none'), 'I have no apples');
});
test('should use the regular key when count property is passed and equal to 1 or not a number', t => {

@@ -117,2 +125,10 @@ const translate = createTranslate({

});
test("should throw error if nested template couldn't be found", t => {
const translate = createTranslate({
foo: 'Foo'
});
t.throws(() => translate('foo.foo_none'), {
message: 'Key foo.foo_none not found!'
});
});
//# sourceMappingURL=translate.js.map

7

es/translate.js

@@ -6,2 +6,3 @@ import _replace from "lodash/fp/replace";

import _has from "lodash/fp/has";
import _getOr from "lodash/fp/getOr";
import _get from "lodash/fp/get";

@@ -11,3 +12,3 @@ const interpolation = /\{\{([\s\S]+?)\}\}/g;

function getTemplate(locales, key, count) {
const regularTemplate = locales[key];
const regularTemplate = _get(key, locales);

@@ -19,3 +20,3 @@ if (!_isNumber(count)) {

if (count === 0) {
return locales[`${key}_none`] || regularTemplate;
return _getOr(regularTemplate, `${key}_none`, locales);
}

@@ -27,3 +28,3 @@

return locales[`${key}_plural`] || regularTemplate;
return _getOr(regularTemplate, `${key}_plural`, locales);
}

@@ -30,0 +31,0 @@

@@ -37,2 +37,10 @@ "use strict";

});
(0, _ava.default)('should accept nested value', t => {
const translate = (0, _translate.default)({
foo: {
foo_none: 'I have no apples'
}
});
t.is(translate('foo.foo_none'), 'I have no apples');
});
(0, _ava.default)('should use the regular key when count property is passed and equal to 1 or not a number', t => {

@@ -123,2 +131,10 @@ const translate = (0, _translate.default)({

});
(0, _ava.default)("should throw error if nested template couldn't be found", t => {
const translate = (0, _translate.default)({
foo: 'Foo'
});
t.throws(() => translate('foo.foo_none'), {
message: 'Key foo.foo_none not found!'
});
});
//# sourceMappingURL=translate.js.map
"use strict";
exports.__esModule = true;
exports.default = void 0;
exports.mockTranslate = mockTranslate;
exports.default = void 0;

@@ -17,2 +17,4 @@ var _replace2 = _interopRequireDefault(require("lodash/fp/replace"));

var _getOr2 = _interopRequireDefault(require("lodash/fp/getOr"));
var _get2 = _interopRequireDefault(require("lodash/fp/get"));

@@ -25,3 +27,3 @@

function getTemplate(locales, key, count) {
const regularTemplate = locales[key];
const regularTemplate = (0, _get2.default)(key, locales);

@@ -33,3 +35,3 @@ if (!(0, _isNumber2.default)(count)) {

if (count === 0) {
return locales[`${key}_none`] || regularTemplate;
return (0, _getOr2.default)(regularTemplate, `${key}_none`, locales);
}

@@ -41,3 +43,3 @@

return locales[`${key}_plural`] || regularTemplate;
return (0, _getOr2.default)(regularTemplate, `${key}_plural`, locales);
}

@@ -44,0 +46,0 @@

{
"name": "@coorpacademy/translate",
"version": "6.1.5",
"version": "6.1.6-alpha.340+87e8913ff",
"description": "",

@@ -50,3 +50,3 @@ "main": "lib/translate.js",

"author": "CoorpAcademy",
"gitHead": "fd256574b0fba67126be17e1498830eac1278c32"
"gitHead": "87e8913fff56755b6f822a3946dfffe2494b09cf"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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