Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ results

npm-debug.log
docs

intl/*
!intl/en/
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
// This file is licensed under the Artistic License 2.0.
// License text available at https://opensource.org/licenses/Artistic-2.0

var SG = require('strong-globalize');
SG.SetRootDir(__dirname);

module.exports = require('./lib/sqlite3.js');
8 changes: 8 additions & 0 deletions intl/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"80a32e80cbed65eba2103201a7c94710": "Model not found: {0}",
"294425a3e64b8afa174c845a84c36565": "Invalid numeric default: {0}",
"3511a3c51942168a860e7f14ce273149": "{{SQLITE3}}: Invalid boolean default: {0}",
"536b28cbb934c78100251d18b1f93c55": "Default value for {0} is not supported",
"a818f6e257ec3de0ee9d3442ec605369": "{{SQLITE3}}: Invalid number: {0}",
"cf1fe185e5c67a821e191ee5fb5ba421": "Invalid date default: {0}"
}
4 changes: 3 additions & 1 deletion lib/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// This file is licensed under the Artistic License 2.0.
// License text available at https://opensource.org/licenses/Artistic-2.0

var g = require('strong-globalize')();

var async = require('async');
var debug = require('debug')('loopback:connector:sqlite3:migration');
var fmt = require('util').format;
Expand Down Expand Up @@ -30,7 +32,7 @@ function mixinMigration(SQLite3) {
async.eachSeries(models, function(model, done) {
if (!(model in self._models)) {
return process.nextTick(function() {
done(new Error('Model not found: ' + model));
done(new Error(g.f('Model not found: %s', model)));
});
}

Expand Down
14 changes: 8 additions & 6 deletions lib/sqlite3.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// This file is licensed under the Artistic License 2.0.
// License text available at https://opensource.org/licenses/Artistic-2.0

var g = require('strong-globalize')();

/*!
* SQLite3 connector for LoopBack
*/
Expand Down Expand Up @@ -372,7 +374,7 @@ function _convertBoolean(value) {
return 1;
if (booleanFalse.indexOf(value) !== -1)
return 0;
return Error('SQLITE3: Invalid boolean default: ' + value);
return Error(g.f('{{SQLITE3}}: Invalid boolean default: %s', value));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to run slt-globalize -e again for intl/en/messages.json to get updated with the brackets change.

}

SQLite3.prototype._getDefaultClause = function(property) {
Expand All @@ -381,7 +383,7 @@ SQLite3.prototype._getDefaultClause = function(property) {

switch (property.type.name) {
case 'Number':
if (isNaN(value)) return Error('Invalid numeric default: ' + value);
if (isNaN(value)) return Error(g.f('Invalid numeric default: %s', value));
return ' DEFAULT ' + Number(value);
case 'Boolean':
return 'DEFAULT ' + _convertBoolean(value);
Expand All @@ -399,7 +401,7 @@ SQLite3.prototype._getDefaultClause = function(property) {
if (!parsedValue.isValid())
return ' DEFAULT ' + (parsedValue.unix() * 1000); // store as ms
}
return Error('Invalid date default: ' + value);
return Error(g.f('Invalid date default: %s', value));
case 'String':
return 'DEFAULT "' + this.escapeValue(value) + '"';
case 'GeoPoint':
Expand All @@ -409,8 +411,8 @@ SQLite3.prototype._getDefaultClause = function(property) {
case 'Object':
case 'JSON':
default:
return Error('Default value for ' + property.type.name +
' is not supported');
return Error(g.f('Default value for %s is not supported',
property.type.name));
}
};

Expand Down Expand Up @@ -520,7 +522,7 @@ SQLite3.prototype.toColumnValue = function(property, value) {
switch (property.type.name) {
case 'Number':
if (isNaN(value))
return new InvalidParam('SQLITE3: Invalid number: ' + value);
return new InvalidParam(g.f('{{SQLITE3}}: Invalid number: %s', value));
return Number(value);
case 'Boolean':
var b = _convertBoolean(value);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"debug": "^2.1.1",
"loopback-connector": "2.x",
"moment": "^2.10.3",
"sqlite3": "^3.1.0"
"sqlite3": "^3.1.0",
"strong-globalize": "^2.5.8"
},
"devDependencies": {
"bluebird": "^2.9.12",
Expand Down