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

react-i18nify

Package Overview
Dependencies
Maintainers
2
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-i18nify - npm Package Compare versions

Comparing version 6.0.0-beta.3 to 6.0.0-beta.4

12

cjs/lib/localize.js

@@ -34,13 +34,15 @@ "use strict";

let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let locale = options.locale || (0, _settings.getLocale)();
if (locale === 'no') locale = 'nb'; // Bokmål as default Norwegian
const locale = options.locale || (0, _settings.getLocale)();
if (options.dateFormat) {
try {
if (_dayjs.default.locale() !== locale) _dayjs.default.locale(locale);
if (_dayjs.default.locale() !== locale) throw new Error('Invalid locale');
let dayJsLocale = locale;
if (locale === 'no') dayJsLocale = 'nb'; // Bokmål as default Norwegian
if (_dayjs.default.locale() !== dayJsLocale) _dayjs.default.locale(dayJsLocale);
if (_dayjs.default.locale() !== dayJsLocale) throw new Error('Invalid locale');
const parsedDate = options.parseFormat ? (0, _dayjs.default)(value, (0, _translate.default)(options.parseFormat, {}, {
locale,
returnKeyOnError: true
}), locale) : (0, _dayjs.default)(value);
}), dayJsLocale) : (0, _dayjs.default)(value);
if (!parsedDate.isValid()) throw new Error('Invalid date');

@@ -47,0 +49,0 @@

@@ -14,13 +14,15 @@ import dayjs from 'dayjs';

let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let locale = options.locale || getLocale();
if (locale === 'no') locale = 'nb'; // Bokmål as default Norwegian
const locale = options.locale || getLocale();
if (options.dateFormat) {
try {
if (dayjs.locale() !== locale) dayjs.locale(locale);
if (dayjs.locale() !== locale) throw new Error('Invalid locale');
let dayJsLocale = locale;
if (locale === 'no') dayJsLocale = 'nb'; // Bokmål as default Norwegian
if (dayjs.locale() !== dayJsLocale) dayjs.locale(dayJsLocale);
if (dayjs.locale() !== dayJsLocale) throw new Error('Invalid locale');
const parsedDate = options.parseFormat ? dayjs(value, translate(options.parseFormat, {}, {
locale,
returnKeyOnError: true
}), locale) : dayjs(value);
}), dayJsLocale) : dayjs(value);
if (!parsedDate.isValid()) throw new Error('Invalid date');

@@ -27,0 +29,0 @@

{
"name": "react-i18nify",
"version": "6.0.0-beta.3",
"version": "6.0.0-beta.4",
"description": "Simple i18n translation and localization components and helpers for React.",

@@ -5,0 +5,0 @@ "main": "./cjs/index.js",

@@ -16,12 +16,14 @@ import dayjs from 'dayjs';

export default (value, options = {}) => {
let locale = options.locale || getLocale();
if (locale === 'no') locale = 'nb'; // Bokmål as default Norwegian
const locale = options.locale || getLocale();
if (options.dateFormat) {
try {
if (dayjs.locale() !== locale) dayjs.locale(locale);
if (dayjs.locale() !== locale) throw new Error('Invalid locale');
let dayJsLocale = locale;
if (locale === 'no') dayJsLocale = 'nb'; // Bokmål as default Norwegian
const parsedDate = options.parseFormat ? dayjs(value, translate(options.parseFormat, {}, { locale, returnKeyOnError: true }), locale) : dayjs(value);
if (dayjs.locale() !== dayJsLocale) dayjs.locale(dayJsLocale);
if (dayjs.locale() !== dayJsLocale) throw new Error('Invalid locale');
const parsedDate = options.parseFormat ? dayjs(value, translate(options.parseFormat, {}, { locale, returnKeyOnError: true }), dayJsLocale) : dayjs(value);
if (!parsedDate.isValid()) throw new Error('Invalid date');

@@ -28,0 +30,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