aurelia-i18n
Advanced tools
Comparing version 1.6.0 to 1.6.1
{ | ||
"name": "aurelia-i18n", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "A plugin that provides i18n support.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,2 +0,2 @@ | ||
define(['exports', 'i18next', 'aurelia-pal', 'aurelia-event-aggregator', 'aurelia-templating-resources'], function (exports, _i18next, _aureliaPal, _aureliaEventAggregator, _aureliaTemplatingResources) { | ||
define(['exports', 'aurelia-logging', 'i18next', 'aurelia-pal', 'aurelia-event-aggregator', 'aurelia-templating-resources'], function (exports, _aureliaLogging, _i18next, _aureliaPal, _aureliaEventAggregator, _aureliaTemplatingResources) { | ||
'use strict'; | ||
@@ -9,2 +9,4 @@ | ||
var LogManager = _interopRequireWildcard(_aureliaLogging); | ||
var _i18next2 = _interopRequireDefault(_i18next); | ||
@@ -18,2 +20,19 @@ | ||
function _interopRequireWildcard(obj) { | ||
if (obj && obj.__esModule) { | ||
return obj; | ||
} else { | ||
var newObj = {}; | ||
if (obj != null) { | ||
for (var key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; | ||
} | ||
} | ||
newObj.default = obj; | ||
return newObj; | ||
} | ||
} | ||
@@ -100,4 +119,8 @@ | ||
var result = number.replace(thousandSeparator, '').replace(/[^\d.,-]/g, '').replace(decimalSeparator, '.'); | ||
if (thousandSeparator === '.') { | ||
thousandSeparator = '\\.'; | ||
} | ||
var result = number.replace(new RegExp(thousandSeparator, 'g'), '').replace(/[^\d.,-]/g, '').replace(decimalSeparator, '.'); | ||
return Number(result); | ||
@@ -191,2 +214,7 @@ }; | ||
}); | ||
var reservedNames = ['prepend', 'append', 'text', 'html']; | ||
if (reservedNames.indexOf(attr) > -1 && node.au && node.au.controller && node.au.controller.viewModel && attrCC in node.au.controller.viewModel) { | ||
var i18nLogger = LogManager.getLogger('i18n'); | ||
i18nLogger.warn('Aurelia I18N reserved attribute name\n\n[' + reservedNames.join(', ') + ']\n\nYour custom element has a bindable named ' + attr + ' which is a reserved word.\n\nIf you\'d like Aurelia I18N to translate your bindable instead, please consider giving it another name.'); | ||
} | ||
@@ -193,0 +221,0 @@ switch (attr) { |
@@ -0,3 +1,3 @@ | ||
import * as LogManager from 'aurelia-logging'; | ||
import i18next from 'i18next'; | ||
import * as LogManager from 'aurelia-logging'; | ||
import { | ||
@@ -4,0 +4,0 @@ resolver |
@@ -0,3 +1,3 @@ | ||
import * as LogManager from 'aurelia-logging'; | ||
import i18next from 'i18next'; | ||
import * as LogManager from 'aurelia-logging'; | ||
import {resolver} from 'aurelia-dependency-injection'; | ||
@@ -548,4 +548,8 @@ import {DOM} from 'aurelia-pal'; | ||
// remove thousand seperator | ||
let result = number.replace(thousandSeparator, '') | ||
if (thousandSeparator === '.') { | ||
thousandSeparator = '\\.'; | ||
} | ||
// remove all thousand seperators | ||
let result = number.replace(new RegExp(thousandSeparator, 'g'), '') | ||
// remove non-numeric signs except -> , . | ||
@@ -656,2 +660,14 @@ .replace(/[^\d.,-]/g, '') | ||
const attrCC = attr.replace(/-([a-z])/g, function(g) { return g[1].toUpperCase(); }); | ||
const reservedNames = ['prepend', 'append', 'text', 'html']; | ||
if (reservedNames.indexOf(attr) > -1 && | ||
node.au && | ||
node.au.controller && | ||
node.au.controller.viewModel && | ||
attrCC in node.au.controller.viewModel) { | ||
const i18nLogger = LogManager.getLogger('i18n'); | ||
i18nLogger.warn(`Aurelia I18N reserved attribute name\n | ||
[${reservedNames.join(', ')}]\n | ||
Your custom element has a bindable named ${attr} which is a reserved word.\n | ||
If you'd like Aurelia I18N to translate your bindable instead, please consider giving it another name.`); | ||
} | ||
@@ -658,0 +674,0 @@ //handle various attributes |
@@ -10,2 +10,6 @@ 'use strict'; | ||
var _aureliaLogging = require('aurelia-logging'); | ||
var LogManager = _interopRequireWildcard(_aureliaLogging); | ||
var _i18next = require('i18next'); | ||
@@ -23,4 +27,6 @@ | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
var I18N = exports.I18N = (_temp = _class = function () { | ||
@@ -103,4 +109,8 @@ function I18N(ea, signaler) { | ||
var result = number.replace(thousandSeparator, '').replace(/[^\d.,-]/g, '').replace(decimalSeparator, '.'); | ||
if (thousandSeparator === '.') { | ||
thousandSeparator = '\\.'; | ||
} | ||
var result = number.replace(new RegExp(thousandSeparator, 'g'), '').replace(/[^\d.,-]/g, '').replace(decimalSeparator, '.'); | ||
return Number(result); | ||
@@ -194,2 +204,7 @@ }; | ||
}); | ||
var reservedNames = ['prepend', 'append', 'text', 'html']; | ||
if (reservedNames.indexOf(attr) > -1 && node.au && node.au.controller && node.au.controller.viewModel && attrCC in node.au.controller.viewModel) { | ||
var i18nLogger = LogManager.getLogger('i18n'); | ||
i18nLogger.warn('Aurelia I18N reserved attribute name\n\n[' + reservedNames.join(', ') + ']\n\nYour custom element has a bindable named ' + attr + ' which is a reserved word.\n\nIf you\'d like Aurelia I18N to translate your bindable instead, please consider giving it another name.'); | ||
} | ||
@@ -196,0 +211,0 @@ switch (attr) { |
var _class, _temp; | ||
import * as LogManager from 'aurelia-logging'; | ||
import i18next from 'i18next'; | ||
@@ -76,4 +77,8 @@ import { DOM } from 'aurelia-pal'; | ||
let result = number.replace(thousandSeparator, '').replace(/[^\d.,-]/g, '').replace(decimalSeparator, '.'); | ||
if (thousandSeparator === '.') { | ||
thousandSeparator = '\\.'; | ||
} | ||
let result = number.replace(new RegExp(thousandSeparator, 'g'), '').replace(/[^\d.,-]/g, '').replace(decimalSeparator, '.'); | ||
return Number(result); | ||
@@ -166,2 +171,10 @@ } | ||
}); | ||
const reservedNames = ['prepend', 'append', 'text', 'html']; | ||
if (reservedNames.indexOf(attr) > -1 && node.au && node.au.controller && node.au.controller.viewModel && attrCC in node.au.controller.viewModel) { | ||
const i18nLogger = LogManager.getLogger('i18n'); | ||
i18nLogger.warn(`Aurelia I18N reserved attribute name\n | ||
[${ reservedNames.join(', ') }]\n | ||
Your custom element has a bindable named ${ attr } which is a reserved word.\n | ||
If you'd like Aurelia I18N to translate your bindable instead, please consider giving it another name.`); | ||
} | ||
@@ -168,0 +181,0 @@ switch (attr) { |
@@ -5,2 +5,3 @@ var _class, _temp; | ||
import * as LogManager from 'aurelia-logging'; | ||
import i18next from 'i18next'; | ||
@@ -88,4 +89,8 @@ import { DOM } from 'aurelia-pal'; | ||
var result = number.replace(thousandSeparator, '').replace(/[^\d.,-]/g, '').replace(decimalSeparator, '.'); | ||
if (thousandSeparator === '.') { | ||
thousandSeparator = '\\.'; | ||
} | ||
var result = number.replace(new RegExp(thousandSeparator, 'g'), '').replace(/[^\d.,-]/g, '').replace(decimalSeparator, '.'); | ||
return Number(result); | ||
@@ -179,2 +184,7 @@ }; | ||
}); | ||
var reservedNames = ['prepend', 'append', 'text', 'html']; | ||
if (reservedNames.indexOf(attr) > -1 && node.au && node.au.controller && node.au.controller.viewModel && attrCC in node.au.controller.viewModel) { | ||
var i18nLogger = LogManager.getLogger('i18n'); | ||
i18nLogger.warn('Aurelia I18N reserved attribute name\n\n[' + reservedNames.join(', ') + ']\n\nYour custom element has a bindable named ' + attr + ' which is a reserved word.\n\nIf you\'d like Aurelia I18N to translate your bindable instead, please consider giving it another name.'); | ||
} | ||
@@ -181,0 +191,0 @@ switch (attr) { |
'use strict'; | ||
System.register(['i18next', 'aurelia-pal', 'aurelia-event-aggregator', 'aurelia-templating-resources'], function (_export, _context) { | ||
System.register(['aurelia-logging', 'i18next', 'aurelia-pal', 'aurelia-event-aggregator', 'aurelia-templating-resources'], function (_export, _context) { | ||
"use strict"; | ||
var i18next, DOM, EventAggregator, BindingSignaler, _class, _temp, I18N; | ||
var LogManager, i18next, DOM, EventAggregator, BindingSignaler, _class, _temp, I18N; | ||
@@ -11,3 +11,5 @@ | ||
return { | ||
setters: [function (_i18next) { | ||
setters: [function (_aureliaLogging) { | ||
LogManager = _aureliaLogging; | ||
}, function (_i18next) { | ||
i18next = _i18next.default; | ||
@@ -99,4 +101,8 @@ }, function (_aureliaPal) { | ||
var result = number.replace(thousandSeparator, '').replace(/[^\d.,-]/g, '').replace(decimalSeparator, '.'); | ||
if (thousandSeparator === '.') { | ||
thousandSeparator = '\\.'; | ||
} | ||
var result = number.replace(new RegExp(thousandSeparator, 'g'), '').replace(/[^\d.,-]/g, '').replace(decimalSeparator, '.'); | ||
return Number(result); | ||
@@ -190,2 +196,7 @@ }; | ||
}); | ||
var reservedNames = ['prepend', 'append', 'text', 'html']; | ||
if (reservedNames.indexOf(attr) > -1 && node.au && node.au.controller && node.au.controller.viewModel && attrCC in node.au.controller.viewModel) { | ||
var i18nLogger = LogManager.getLogger('i18n'); | ||
i18nLogger.warn('Aurelia I18N reserved attribute name\n\n[' + reservedNames.join(', ') + ']\n\nYour custom element has a bindable named ' + attr + ' which is a reserved word.\n\nIf you\'d like Aurelia I18N to translate your bindable instead, please consider giving it another name.'); | ||
} | ||
@@ -192,0 +203,0 @@ switch (attr) { |
@@ -12,2 +12,6 @@ 'use strict'; | ||
var _aureliaLogging = require('aurelia-logging'); | ||
var LogManager = _interopRequireWildcard(_aureliaLogging); | ||
var _i18next = require('i18next'); | ||
@@ -17,6 +21,2 @@ | ||
var _aureliaLogging = require('aurelia-logging'); | ||
var LogManager = _interopRequireWildcard(_aureliaLogging); | ||
var _aureliaDependencyInjection = require('aurelia-dependency-injection'); | ||
@@ -36,6 +36,6 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -585,4 +585,8 @@ | ||
var result = number.replace(thousandSeparator, '').replace(/[^\d.,-]/g, '').replace(decimalSeparator, '.'); | ||
if (thousandSeparator === '.') { | ||
thousandSeparator = '\\.'; | ||
} | ||
var result = number.replace(new RegExp(thousandSeparator, 'g'), '').replace(/[^\d.,-]/g, '').replace(decimalSeparator, '.'); | ||
return Number(result); | ||
@@ -676,2 +680,7 @@ }; | ||
}); | ||
var reservedNames = ['prepend', 'append', 'text', 'html']; | ||
if (reservedNames.indexOf(attr) > -1 && node.au && node.au.controller && node.au.controller.viewModel && attrCC in node.au.controller.viewModel) { | ||
var i18nLogger = LogManager.getLogger('i18n'); | ||
i18nLogger.warn('Aurelia I18N reserved attribute name\n\n[' + reservedNames.join(', ') + ']\n\nYour custom element has a bindable named ' + attr + ' which is a reserved word.\n\nIf you\'d like Aurelia I18N to translate your bindable instead, please consider giving it another name.'); | ||
} | ||
@@ -678,0 +687,0 @@ switch (attr) { |
@@ -166,3 +166,3 @@ --- | ||
import {I18N, Backend} from 'aurelia-i18n'; | ||
import {I18N, Backend, TCustomAttribute} from 'aurelia-i18n'; | ||
@@ -203,3 +203,3 @@ export function configure(aurelia) { | ||
import {I18N} from 'aurelia-i18n'; | ||
import {I18N, TCustomAttribute} from 'aurelia-i18n'; | ||
import Backend from 'i18next-xhr-backend'; // <-- your previously installed backend plugin | ||
@@ -206,0 +206,0 @@ |
@@ -0,1 +1,14 @@ | ||
<a name="1.6.1"></a> | ||
## [1.6.1](https://github.com/aurelia/i18n/compare/1.6.0...v1.6.1) (2017-05-31) | ||
### Bug Fixes | ||
* **t-attribute:** warning when using reserved word ([a5b833f](https://github.com/aurelia/i18n/commit/a5b833f)), closes [/github.com/aurelia/i18n/issues/218#issuecomment-304611266](https://github.com//github.com/aurelia/i18n/issues/218/issues/issuecomment-304611266) | ||
* **uf:** properly escape dot in RegExp ([0ee7dbb](https://github.com/aurelia/i18n/commit/0ee7dbb)) | ||
* **uf():** remove all thousand separators ([5741270](https://github.com/aurelia/i18n/commit/5741270)) | ||
* **uf():** remove all thousand seperators ([40f549d](https://github.com/aurelia/i18n/commit/40f549d)) | ||
<a name="1.6.0"></a> | ||
@@ -2,0 +15,0 @@ # [1.6.0](https://github.com/aurelia/i18n/compare/1.5.1...v1.6.0) (2017-04-27) |
{ | ||
"name": "aurelia-i18n", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "A plugin that provides i18n support.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
/*eslint no-cond-assign: 0*/ | ||
import * as LogManager from 'aurelia-logging'; | ||
import i18next from 'i18next'; | ||
@@ -79,4 +80,8 @@ import {DOM} from 'aurelia-pal'; | ||
// remove thousand seperator | ||
let result = number.replace(thousandSeparator, '') | ||
if (thousandSeparator === '.') { | ||
thousandSeparator = '\\.'; | ||
} | ||
// remove all thousand seperators | ||
let result = number.replace(new RegExp(thousandSeparator, 'g'), '') | ||
// remove non-numeric signs except -> , . | ||
@@ -187,2 +192,14 @@ .replace(/[^\d.,-]/g, '') | ||
const attrCC = attr.replace(/-([a-z])/g, function(g) { return g[1].toUpperCase(); }); | ||
const reservedNames = ['prepend', 'append', 'text', 'html']; | ||
if (reservedNames.indexOf(attr) > -1 && | ||
node.au && | ||
node.au.controller && | ||
node.au.controller.viewModel && | ||
attrCC in node.au.controller.viewModel) { | ||
const i18nLogger = LogManager.getLogger('i18n'); | ||
i18nLogger.warn(`Aurelia I18N reserved attribute name\n | ||
[${reservedNames.join(', ')}]\n | ||
Your custom element has a bindable named ${attr} which is a reserved word.\n | ||
If you'd like Aurelia I18N to translate your bindable instead, please consider giving it another name.`); | ||
} | ||
@@ -189,0 +206,0 @@ //handle various attributes |
@@ -76,13 +76,13 @@ import {I18N} from '../../src/i18n'; | ||
it('should keep the decimal separator', () => { | ||
let sample = '1,234.56'; | ||
let sample = '1,234,567.89'; | ||
let result = sut.uf(sample); | ||
expect(result).toBe(1234.56); | ||
expect(result).toBe(1234567.89); | ||
}); | ||
it('should respect provided locale', () => { | ||
let sample = '1.234,56'; | ||
let sample = '1.234.567,89'; | ||
let result = sut.uf(sample, 'de'); | ||
expect(result).toBe(1234.56); | ||
expect(result).toBe(1234567.89); | ||
}); | ||
@@ -89,0 +89,0 @@ |
558118
11447