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

react-intl-po

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-intl-po - npm Package Compare versions

Comparing version 1.0.7 to 1.0.9

7

CHANGELOG.md

@@ -6,2 +6,7 @@ # react-intl-po

## [v1.0.9]
> Sep 21, 2016
* fix(DEFAULT_MAPPER): prefix is not required anymore. ([@eliseumds](https://github.com/eliseumds) in [#19], [@MorrisGallego](https://github.com/MorrisGallego) in [#34])
## [v1.0.7]

@@ -11,3 +16,3 @@ > Sep 13, 2016

* test(structure): move output .temp file into the temp folder for gitignore.
* feat(po2json): added generation of one output file per input if the specified output is a folder. [@MorrisGallego](https://github.com/MorrisGallego) in [#29]
* feat(po2json): added generation of one output file per input if the specified output is a folder. ([@MorrisGallego](https://github.com/MorrisGallego) in [#29])

@@ -14,0 +19,0 @@ ## [v1.0.6]

20

lib/readAllPOAsObjectSync.js

@@ -6,5 +6,10 @@ 'use strict';

});
exports.DEFAULT_MAPPER = undefined;
var _glob = require('glob');
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _po2json = require('po2json');

@@ -26,4 +31,4 @@

var DEFAULT_MAPPER = function DEFAULT_MAPPER(filename) {
return filename.match(/[^.]\.(.*)\.po$/)[1];
var DEFAULT_MAPPER = exports.DEFAULT_MAPPER = function DEFAULT_MAPPER(filepath) {
return _path2.default.basename(filepath).match(/([^.]*\.)*([^.]+)\.po$/)[2];
};

@@ -44,10 +49,10 @@

var filenames = (0, _glob.sync)(srcPatterns);
var filepaths = (0, _glob.sync)(srcPatterns);
return (0, _toObjectBy2.default)(filenames, function (filename) {
var json = _po2json2.default.parseFileSync(filename);
return (0, _toObjectBy2.default)(filepaths, function (filepath) {
var json = _po2json2.default.parseFileSync(filepath);
var translated = (0, _mapValues2.default)(json, function (o) {
return o[1];
}); // omit plural
var locale = localeMapper(filename); // parse locale name
var locale = localeMapper(filepath); // parse locale name

@@ -58,3 +63,2 @@ return _defineProperty({}, locale, translated);

exports.default = readAllPOAsObjectSync;
module.exports = exports['default'];
exports.default = readAllPOAsObjectSync;
{
"name": "react-intl-po",
"version": "1.0.7",
"version": "1.0.9",
"description": "Extract POT from react-intl and convert back to json.",

@@ -5,0 +5,0 @@ "author": "Michael Hsu",

import { sync as globSync } from 'glob';
import path from 'path';
import po2json from 'po2json';

@@ -6,4 +7,4 @@ import mapValues from 'lodash/mapValues';

const DEFAULT_MAPPER = (filename) =>
filename.match(/[^.]\.(.*)\.po$/)[1];
export const DEFAULT_MAPPER = (filepath) =>
path.basename(filepath).match(/([^.]*\.)*([^.]+)\.po$/)[2];

@@ -21,8 +22,8 @@ /**

function readAllPOAsObjectSync(srcPatterns, localeMapper = DEFAULT_MAPPER) {
const filenames = globSync(srcPatterns);
const filepaths = globSync(srcPatterns);
return toObjectBy(filenames, filename => {
const json = po2json.parseFileSync(filename);
return toObjectBy(filepaths, filepath => {
const json = po2json.parseFileSync(filepath);
const translated = mapValues(json, o => o[1]); // omit plural
const locale = localeMapper(filename); // parse locale name
const locale = localeMapper(filepath); // parse locale name

@@ -29,0 +30,0 @@ return {

import test from 'ava';
import readAllPOAsObjectSync from '../src/readAllPOAsObjectSync';
import {
default as readAllPOAsObjectSync,
DEFAULT_MAPPER as defaultMapper,
} from '../src/readAllPOAsObjectSync';

@@ -8,2 +11,20 @@ test('should return a function', t => {

test('should return locale when DEFAULT_MAPPER w/o prefix', t => {
t.is(defaultMapper('mcs-public.zh-CN.po'), 'zh-CN');
t.is(defaultMapper('mcs-public.zh-TW.po'), 'zh-TW');
t.is(defaultMapper('mcs-public.en.po'), 'en');
t.is(defaultMapper('./node_modules/mcs-translation/po/mcs-public.zh-cn.po'), 'zh-cn');
t.is(defaultMapper('./node_modules/mcs-translation/po/mcs-public.zh-tw.po'), 'zh-tw');
t.is(defaultMapper('./node_modules/mcs-translation/po/mcs-public.en.po'), 'en');
t.is(defaultMapper('./node_modules/mcs-translation/po/zh-CN.po'), 'zh-CN');
t.is(defaultMapper('./node_modules/mcs-translation/po/zh-TW.po'), 'zh-TW');
t.is(defaultMapper('./node_modules/mcs-translation/po/en.po'), 'en');
t.is(defaultMapper('zh-CN.po'), 'zh-CN');
t.is(defaultMapper('zh-TW.po'), 'zh-TW');
t.is(defaultMapper('en.po'), 'en');
});
test('should return po object with default localeMapper', t => {

@@ -10,0 +31,0 @@ t.deepEqual(

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