react-i18nify
Advanced tools
Comparing version 1.11.9 to 1.11.10
@@ -125,11 +125,20 @@ 'use strict'; | ||
var moduleAvailable = function moduleAvailable(name) { | ||
try { | ||
require.resolve(name); | ||
return true; | ||
} catch (e) { | ||
// do nothing | ||
} | ||
return false; | ||
}; | ||
if (options.dateFormat) { | ||
try { | ||
if (moduleAvailable('moment')) { | ||
var moment = require('moment'); | ||
require('moment/min/locales'); | ||
return moment(value, options.parseFormat, this._locale, Boolean(options.strictParse)).format(this.t(options.dateFormat)); | ||
} catch (e) { | ||
console.error('moment.js error', e); | ||
return ''; | ||
} | ||
console.error('Date formatting failed, please install moment.js'); | ||
return ''; | ||
} | ||
@@ -136,0 +145,0 @@ if (typeof value === 'number') { |
@@ -27,3 +27,3 @@ const React = require('react'); | ||
export_1: 'Export %{count} item', | ||
two_lines: 'Line 1<br />Line 2', | ||
two_lines: 'Line 1< sbr />Line 2', | ||
}, | ||
@@ -30,0 +30,0 @@ nl: { |
{ | ||
"name": "react-i18nify", | ||
"version": "1.11.9", | ||
"version": "1.11.10", | ||
"description": "Simple i18n translation and localization components and helpers for React applications.", | ||
@@ -5,0 +5,0 @@ "main": "./build/index.js", |
@@ -113,4 +113,14 @@ /* eslint global-require: "off" */ | ||
_localize(value, options = {}) { | ||
const moduleAvailable = (name) => { | ||
try { | ||
require.resolve(name); | ||
return true; | ||
} catch (e) { | ||
// do nothing | ||
} | ||
return false; | ||
}; | ||
if (options.dateFormat) { | ||
try { | ||
if (moduleAvailable('moment')) { | ||
const moment = require('moment'); | ||
@@ -124,6 +134,5 @@ require('moment/min/locales'); | ||
).format(this.t(options.dateFormat)); | ||
} catch (e) { | ||
console.error('moment.js error', e); | ||
return ''; | ||
} | ||
console.error('Date formatting failed, please install moment.js'); | ||
return ''; | ||
} | ||
@@ -130,0 +139,0 @@ if (typeof value === 'number') { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38504
712
2