Add globalization

This commit is contained in:
Simon Ho 2016-07-27 15:45:24 -07:00
parent acddef4223
commit 35c93eb59f
6 changed files with 22 additions and 3 deletions

3
.gitignore vendored
View File

@ -19,3 +19,6 @@ npm-debug.log
node_modules
LoopBackExplorer.iml
intl/*
!intl/en/

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
var g = require('strong-globalize')();
var loopback = require('loopback');
var app = loopback();
var explorer = require('../');
@ -20,6 +22,6 @@ app.model(User);
var apiPath = '/api';
explorer(app, { basePath: apiPath });
app.use(apiPath, loopback.rest());
console.log('Explorer mounted at localhost:' + port + '/explorer');
g.log('{{Explorer}} mounted at {{localhost:%s/explorer}}', port);
app.listen(port);

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
var g = require('strong-globalize')();
var loopback = require('loopback');
var app = loopback();
var explorer = require('../');
@ -19,6 +21,6 @@ app.model(Product);
var apiPath = '/api';
explorer(app, { basePath: apiPath });
app.use(apiPath, loopback.rest());
console.log('Explorer mounted at http://localhost:' + port + '/explorer');
g.log('{{Explorer}} mounted at {{http://localhost:%s/explorer}}', port);
app.listen(port);

View File

@ -4,6 +4,11 @@
// License text available at https://opensource.org/licenses/MIT
'use strict';
var SG = require('strong-globalize');
SG.SetRootDir(__dirname);
var g = SG();
/*!
* Adds dynamically-updated docs as /explorer
*/
@ -38,7 +43,8 @@ function routes(loopbackApplication, options) {
loopback.version.split('.')[0] || 1;
if (loopbackMajor < 2) {
throw new Error('loopback-component-explorer requires loopback 2.0 or newer');
throw new Error(g.f('{{loopback-component-explorer}} requires ' +
'{{loopback}} 2.0 or newer'));
}
options = _defaults({}, options, {

5
intl/en/messages.json Normal file
View File

@ -0,0 +1,5 @@
{
"b9e94c12da3208f46a969191874c425c": "{{Explorer}} mounted at {{localhost:{0}/explorer}}",
"88bef790f515ec7b7af0c6871e60c077": "{{Explorer}} mounted at {{http://localhost:{0}/explorer}}",
"f3f2b04c273e23780d76306f8c72a60f": "{{loopback-component-explorer}} requires {{loopback}} 2.0 or newer"
}

View File

@ -36,6 +36,7 @@
"debug": "^2.2.0",
"lodash": "^3.10.0",
"loopback-swagger": "^2.1.0",
"strong-globalize": "^2.6.2",
"strong-swagger-ui": "^21.0.0"
}
}