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 @@ -12,3 +12,6 @@ docs/man
npm-debug.log
.project
test/memory.json
intl/*
!intl/en/

3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

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

exports.ModelBuilder = exports.LDL = require('./lib/model-builder.js').ModelBuilder;
exports.DataSource = exports.Schema = require('./lib/datasource.js').DataSource;
exports.ModelBaseClass = require('./lib/model.js');
Expand Down
69 changes: 69 additions & 0 deletions intl/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"4c78325cedbb826db3a05bf5df0e8546": "You must provide an {{id}} when replacing!",
"a0cf0e09c26df14283223e84e6a10f00": "Could not update attributes. {{Object}} with {{id}} {0} does not exist!",
"e54d944c2a2c85a23caa86027ae307cf": "Cannot migrate models not attached to this datasource: {0}",
"e6161ae8459c79d810e2aa9d21282a39": "You must provide an {{id}} when updating attributes!",
"fca4d12faff1035d9d0438d73432571b": "Duplicate entry for {0}.{1}",
"09483e03b91c8bd58732a74b3ef1ec13": "Invalid date: {0}",
"0b16d3ffc42f91b4b9a4b3b50c41c838": "The order {0} is not valid",
"0e88a84c6bc2638fbcc5d3ea95181f99": "Unknown property: {0}",
"21095484501dbff31af6556fa6039182": "The {{offset/skip}} parameter {0} is not valid",
"416dfbb7b823f51c9f3800be81060b41": "No instance with {{id}} {0} found for {1}",
"4e31b1edd10dadb724d83387de0b5062": "The {{limit}} parameter {0} is not valid",
"5ec8efeb715a2c34b440f2d76e2cf87d": " {0}",
"62a2d80c405b7fec5f547c448ab1b6ff": "The {{order}} {0} has invalid direction",
"63f503acabdc4c7588aab741b8466862": "The {0} property has invalid clause {1}",
"6c3234937d69763fc7f6bcafccc59bbc": "{{Model::deleteById}} requires the {{id}} argument",
"6eb6fd4fbd73394000bc25f5776fd20c": "{{Model::exists}} requires the {{id}} argument",
"7bbbdece4eea90e42aa5c0bce295e503": "{{Model::findById}} requires the {{id}} argument",
"9da58ab4555ac50f4999883de6470d7d": "The {0} operator has invalid clauses {1}",
"a829dee089c912e68c18920ba015400c": "WARNING: {{id}} property cannot be changed from {0} to {1} for model:{2} in {{'loaded'}} operation hook",
"a984a076c59e451948b2bcf7a393d860": "WARNING: {{id}} property cannot be changed from {0} to {1} for model:{2} in {{'before save'}} operation hook",
"baf2c8b0c5a574b8a894e9b6304fece1": "The where clause {0} is not an {{object}}",
"db03083e9a768388fdbee865249ac67a": "Ignoring validation errors in {{updateOrCreate()}}:",
"e4434de4bb8f5a3cd1d416e4d80d7e0b": "Unknown \"{0}\" {{id}} \"{1}\".",
"e54f118a75e15e132f16b985274eb46d": "The query filter {0} is not an {{object}}",
"f6e8c96c93b9c7687d6c172b3695e898": "{{id}} property ({0}) cannot be updated from {1} to {2}",
"0be2d39d225b1d8b2a0f92ad5c65c9ac": "No model specified for {{polymorphic}} {0}: {1}",
"2f4af31c144bbfab1bbf479866acd820": "\nWARNING: {{LoopBack}} connector \"{0}\" is not installed as any of the following modules:\n\n {1}\n\nTo fix, run:\n\n {{npm install {2} --save}}\n",
"6111399276924ffa3bc9a410cdfcb2e5": "No {{id}} name {0}",
"791ab3031a73ede03f7d6299a85e8289": "Timeout in connecting after {0} ms",
"7b277018e43d41bc445731092b91547d": "Not connected",
"a2487abefef4259c2131d96cdb8543b1": "Connection fails: {0}\nIt will be retried for the next request.",
"b15b20280211ad258d92947f05b6e4a5": "The connector has not been initialized.",
"ddf0aa14803f1c84f4a97f3803f7471c": "Class name required",
"e0e9504e137a3c3339144b51ed76fef2": "Connector is not defined correctly: it should create `{{connector}}` member of dataSource",
"ec42dca074f1818c447f7ad16e2d01af": "{0} is not provided by the attached connector",
"ba0fd8106eb54de4d003a844206431fd": "Model hook \"{0}\" is deprecated, use Operation hooks instead. {{http://docs.strongloop.com/display/LB/Operation+hooks}}",
"280f4550f90e133118955ec6f6f72830": "Discriminator type {0} specified but no model exists with such name",
"38dbf42c29a4645238cc3d632e88ebc9": "{{Relation.modelTo}} is not defined for relation {0} and is no {{polymorphic}}",
"eb56c2b0c30cf006e2df00a549ec9c2c": "Relation \"{0}\" is not defined for {1} model",
"938401ea4ce48159efa9be1d4a5e8bab": "Items must be an array: {0}",
"f41bd91dc0f000a79c0bf842f1b7fdf9": "could not create List from JSON string: {0}",
"514985b2327f061ffb1c932f6b909979": "Model {0} is not defined.",
"cc09e361de7b0f3dc1687515c5713885": "Property names containing a dot are not supported. Model: {0}, property: {1}",
"da02dd6c53d4148320eeb31718a7aebe": "Invalid type for property {0}",
"1853f9414bc61ed196952f5c81e41802": "Property names containing a dot are not supported. Model: {0}, dynamic property: {1}",
"bdb11cc1c780c9ccac33c316cfdc9d82": "Type not defined for property {0}.{1}",
"cd930369e86cdd222f7bd117c6f9fa94": "Unknown default value provider {0}",
"0c0b867aca0973ba26e887d3337cc4ec": "{{Polymorphic}} model not found: `{0}` not set",
"2f062cbecdf24245731bddc77714c814": "Could not find \"{0}\" relation for {1}",
"3cde8cc9bca22c67278b202ab0720106": "No instance with id {0} found for {1}",
"6502a117987610380b9068ef98b1b0ee": "No record found in {0} for ({1}.{2} ,{3}.{4})",
"6fcc2ff0db7a4f490f5e0ce9e24691f3": "{{HasOne}} relation cannot create more than one instance of {0}",
"7e9530c0399289be0ee601a604be71ff": "{{BelongsTo}} relation {0} is empty",
"7faa840eb6ce11250a141deb42a6c489": "Unknown relation {{scope}}: {0}",
"89afd3a9249f5a8d3edda07d84ca049d": "{{Polymorphic}} model not found: `{0}`",
"a004f310d315e592843776fab964eaeb": "{{Polymorphic}} relations need a through model",
"a25e41a39c60c4702e55d0c3936576a1": "Key mismatch: {0}.{1}: {2}, {3}.{4}: {5}",
"a327355560d495454fba2c1aad6bdf09": "Unknown scope method: {0}",
"e08ab0e1ab55f26c357061447b635905": "No relation found in {0} for ({1}.{2},{3}.{4})",
"e55937649d8d7a11706b8cec22d02eae": "{{HasOne}} relation {0} is empty",
"2c4904377a87fdab502118719cc0d266": "{{Transaction}} is not supported",
"ecb7aa804bf54c682999d20d6436104c": "The {{transaction}} is not active: {0}",
"89bf6d92731fe7bd2146ce8d0bec205c": "Invalid argument, must be a string, {{regex}} literal, or {{RegExp}} object",
"8c5ab01638c1ac1d58168c6346a8481a": "Invalid {{regex}} flags: {0}",
"a6c18a7f4390cd3d59a2a7a047ae2aab": "Run \"{{npm install loopback-datasource-juggler}} {0}\" command ",
"b138294f132edfe1eb2a8211150c7238": "Unexpected `undefined` in query",
"8a39126103a157f501affa070367a1b0": "The {0} instance is not valid. Details: {1}."
}
13 changes: 7 additions & 6 deletions lib/connectors/memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

var g = require('strong-globalize')();
var util = require('util');
var Connector = require('loopback-connector').Connector;
var geo = require('../geo');
Expand Down Expand Up @@ -217,7 +218,7 @@ Memory.prototype._createSync = function(model, data, fn) {
}

if (this.collection(model)[id])
return fn(new Error('Duplicate entry for ' + model + '.' + idName));
return fn(new Error(g.f('Duplicate entry for %s.%s', model, idName)));

this.collection(model)[id] = serialize(data);
fn(null, id);
Expand Down Expand Up @@ -702,7 +703,7 @@ Memory.prototype.update =

Memory.prototype.updateAttributes = function updateAttributes(model, id, data, options, cb) {
if (!id) {
var err = new Error('You must provide an id when updating attributes!');
var err = new Error(g.f('You must provide an {{id}} when updating attributes!'));
if (cb) {
return cb(err);
} else {
Expand All @@ -721,14 +722,14 @@ Memory.prototype.updateAttributes = function updateAttributes(model, id, data, o
if (modelData) {
this.save(model, data, options, cb);
} else {
cb(new Error('Could not update attributes. Object with id ' + id + ' does not exist!'));
cb(new Error(g.f('Could not update attributes. {{Object}} with {{id}} %s does not exist!', id)));
}
};

Memory.prototype.replaceById = function(model, id, data, options, cb) {
var self = this;
if (!id) {
var err = new Error('You must provide an id when replacing!');
var err = new Error(g.f('You must provide an {{id}} when replacing!'));
return process.nextTick(function() { cb(err); });
}
// Do not modify the data object passed in arguments
Expand Down Expand Up @@ -819,8 +820,8 @@ Memory.prototype.automigrate = function(models, cb) {

if (invalidModels.length) {
return process.nextTick(function() {
cb(new Error('Cannot migrate models not attached to this datasource: ' +
invalidModels.join(' ')));
cb(new Error(g.f('Cannot migrate models not attached to this datasource: %s',
invalidModels.join(' '))));
});
}

Expand Down
3 changes: 2 additions & 1 deletion lib/connectors/transient.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

var g = require('strong-globalize')();
var util = require('util');
var Connector = require('loopback-connector').Connector;
var utils = require('../utils');
Expand Down Expand Up @@ -108,7 +109,7 @@ Transient.prototype.update =

Transient.prototype.updateAttributes = function updateAttributes(model, id, data, cb) {
if (!id) {
var err = new Error('You must provide an id when updating attributes!');
var err = new Error(g.f('You must provide an {{id}} when updating attributes!'));
if (cb) {
return cb(err);
} else {
Expand Down
Loading