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

react-i18nify

Package Overview
Dependencies
Maintainers
1
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 1.2.0 to 1.2.1

example.js

28

build/index.js

@@ -6,20 +6,28 @@ 'use strict';

});
exports.Localize = exports.Translate = exports.I18n = undefined;
var _I18n = require('./lib/I18n');
var _I18n2 = _interopRequireDefault(_I18n);
Object.defineProperty(exports, 'I18n', {
enumerable: true,
get: function get() {
return _I18n.I18n;
}
});
var _Translate = require('./lib/Translate');
var _Translate2 = _interopRequireDefault(_Translate);
Object.defineProperty(exports, 'Translate', {
enumerable: true,
get: function get() {
return _Translate.Translate;
}
});
var _Localize = require('./lib/Localize');
var _Localize2 = _interopRequireDefault(_Localize);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.I18n = _I18n2.default;
exports.Translate = _Translate2.default;
exports.Localize = _Localize2.default;
Object.defineProperty(exports, 'Localize', {
enumerable: true,
get: function get() {
return _Localize.Localize;
}
});

@@ -11,6 +11,4 @@ 'use strict';

var _locales = require('moment/min/locales');
require('moment/min/locales');
var _locales2 = _interopRequireDefault(_locales);
var _intl = require('intl');

@@ -17,0 +15,0 @@

@@ -6,2 +6,3 @@ 'use strict';

});
exports.default = Localize;

@@ -18,30 +19,14 @@ var _react = require('react');

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function Localize(_ref) {
var value = _ref.value;
var options = _ref.options;
var dateFormat = _ref.dateFormat;
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
return _react2.default.createElement(
'span',
null,
_I18n2.default._localize(value, dateFormat ? { dateFormat: dateFormat } : options)
);
}
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Localize = function (_React$Component) {
_inherits(Localize, _React$Component);
function Localize() {
var _Object$getPrototypeO;
var _temp, _this, _ret;
_classCallCheck(this, Localize);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Localize)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.render = function () {
return _react2.default.createElement('span', {}, _I18n2.default._localize(_this.props.value, _this.props.dateFormat ? { dateFormat: _this.props.dateFormat } : _this.props.options));
}, _temp), _possibleConstructorReturn(_this, _ret);
}
return Localize;
}(_react2.default.Component);
Localize.propTypes = {

@@ -51,3 +36,2 @@ value: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.number, _react2.default.PropTypes.object]).isRequired,

dateFormat: _react2.default.PropTypes.string
};
exports.default = Localize;
};

@@ -44,3 +44,7 @@ 'use strict';

}, _this.render = function () {
return _react2.default.createElement('span', {}, _I18n2.default._translate(_this.props.value, _this.otherProps()));
return _react2.default.createElement(
'span',
null,
_I18n2.default._translate(_this.props.value, _this.otherProps())
);
}, _temp), _possibleConstructorReturn(_this, _ret);

@@ -47,0 +51,0 @@ }

const gulp = require('gulp');
const eslint = require('gulp-eslint');
const babel = require("gulp-babel");
require('gulp-dev-tasks');
gulp.task('lint', function() {
return gulp.src('src/**/*.js')
.pipe(eslint())
.pipe(eslint.format());
});
const source = ['src/**/*.js', 'src/**/*.jsx'];
gulp.task('lint:fix', function() {
return gulp.src('src/**/*.js', {base: '.'})
.pipe(eslint({fix: true}))
.pipe(gulp.dest('.'))
.pipe(eslint.format());
});
gulp.task('build', function() {
return gulp.src('src/**/*.js')
return gulp.src(source)
.pipe(babel({presets: ['es2015', 'react', 'stage-1']}))

@@ -25,3 +14,3 @@ .pipe(gulp.dest('build/'));

gulp.task('default', ['lint', 'build'], function() {
gulp.watch('src/**/*.js', ['lint', 'build']);
gulp.watch(source, ['lint', 'build']);
});
{
"name": "react-i18nify",
"version": "1.2.0",
"version": "1.2.1",
"description": "Simple i18n translation and localization components and helpers for React applications.",

@@ -26,20 +26,16 @@ "main": "./build/index.js",

],
"tonicExampleFilename": "example.js",
"dependencies": {
"intl": "^1.1",
"moment": "^2.12.0",
"react": "^15.0.0"
"intl": "^1.2",
"moment": "^2.13.0",
"react": "^15.1.0"
},
"devDependencies": {
"babel-eslint": "^6.0.2",
"babel-preset-es2015": "^6.6.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-1": "^6.5.0",
"eslint-config-airbnb": "^6.2.0",
"eslint-plugin-react": "^4.3.0",
"estraverse": "^4.2.0",
"estraverse-fb": "^1.3.1",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-eslint": "^2.0.0"
"gulp-dev-tasks": "^1.0.23"
}
}

@@ -6,2 +6,6 @@ # react-i18nify

A working example of this package can be found [here at Tonic](https://tonicdev.com/npm/react-i18nify).
If you're using Redux or Fluxible, feel free to use [react-redux-i18n](https://github.com/zoover/react-redux-i18n) or [react-fluxible-i18n](https://github.com/zoover/react-fluxible-i18n) instead.
## Preparation

@@ -14,3 +18,3 @@

Next, load the translations to be used, for example in `app.js`:
Next, load the translations and locale to be used:
```javascript

@@ -39,16 +43,11 @@ var I18n = require('react-i18nify').I18n;

});
I18n.setLocale('nl');
```
Finally, you should set the locale to be used:
Alternatively, you can provide a callback to return the translations and locale to
`setTranslationsGetter` and `setLocaleGetter` respectively.
```javascript
var I18n = require('react-i18nify').I18n;
I18n.setLocale('nl');
```
## Alternative callbacks usage
You can provide a callback that return a translations object, a locale key to
`setTranslationsGetter` and `setLocaleGetter` respectively.
```
function translation() {

@@ -77,4 +76,8 @@ return {

function locale() {
return 'nl';
}
I18n.setTranslationsGetter(translations):
I18n.setLocaleGetter(function() { return 'nl'; });
I18n.setLocaleGetter(locale);
```

@@ -116,3 +119,3 @@ Now you're all set up to start unleashing the power of `react-i18nify`!

I18n.t('application.title'); // => returns 'Toffe app met i18n!' for locale 'nl'
I18n.t('application.name', {name: 'Aad'}); // => returns 'Hallo, Aad!' for locale 'nl'
I18n.t('application.hello', {name: 'Aad'}); // => returns 'Hallo, Aad!' for locale 'nl'

@@ -119,0 +122,0 @@ I18n.l(1385856000000, { dateFormat: 'date.long' }); // => returns '1 december 2013' for locale 'nl'

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

import I18n from './lib/I18n';
export { I18n };
import Translate from './lib/Translate';
export { Translate };
import Localize from './lib/Localize';
export { Localize };
export { I18n } from './lib/I18n';
export { Translate } from './lib/Translate';
export { Localize } from './lib/Localize';
import moment from 'moment';
import locales from 'moment/min/locales';
import 'moment/min/locales';
import IntlPolyfill from 'intl';

@@ -4,0 +4,0 @@

import React from 'react';
import I18n from './I18n';
export default class Localize extends React.Component {
static propTypes = {
value: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number,
React.PropTypes.object]).isRequired,
options: React.PropTypes.object,
dateFormat: React.PropTypes.string,
};
render = () => React.createElement(
'span',
{},
I18n._localize(
this.props.value,
this.props.dateFormat ? { dateFormat: this.props.dateFormat } : this.props.options
)
export default function Localize({ value, options, dateFormat }) {
return (
<span>
{I18n._localize(value, dateFormat ? { dateFormat } : options)}
</span>
);
}
Localize.propTypes = {
value: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number,
React.PropTypes.object]).isRequired,
options: React.PropTypes.object,
dateFormat: React.PropTypes.string,
};

@@ -15,10 +15,7 @@ import React from 'react';

render = () => React.createElement(
'span',
{},
I18n._translate(
this.props.value,
this.otherProps()
)
render = () => (
<span>
{I18n._translate(this.props.value, this.otherProps())}
</span>
);
}
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