Skip to content

Commit 4a1b9b5

Browse files
author
David Cheung
committed
Globalize loopback-angular-sdk-cli
note that `lb-ng` is changed to `lb-ng.js` because slt-globalize checks files based on file extension
1 parent 1134b80 commit 4a1b9b5

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@
1212
*.swo
1313
node_modules
1414
/test/sandbox
15+
intl/*
16+
!intl/en/

bin/lb-ng renamed to bin/lb-ng.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
#!/usr/bin/env node
22

3-
var fs = require('fs');
43
var path = require('path');
4+
var SG = require('strong-globalize');
5+
SG.SetRootDir(path.resolve(__dirname, '..'));
6+
var g = SG();
7+
var fs = require('fs');
58
var semver = require('semver');
69
var optimist = require('optimist');
710
var generator = require('loopback-sdk-angular');
811

912
var argv = optimist
10-
.usage('Generate Angular $resource services for your LoopBack application.' +
13+
.usage(g.f(
14+
'Generate {{Angular $resource}} services ' +
15+
'for your {{LoopBack}} application.' +
1116
'\nUsage:' +
12-
'\n $0 [options] server/app.js [client/js/lb-services.js]')
13-
.describe('m', 'The name for generated Angular module.')
17+
'\n $0 {{[options] server/app.js [client/js/lb-services.js]}}'))
18+
.describe('m', g.f('The name for generated {{Angular}} module.'))
1419
.default('m', 'lbServices')
15-
.describe('u', 'URL of the REST API end-point')
20+
.describe('u', g.f('URL of the REST API end-point'))
1621
.alias({ u : 'url', m: 'module-name' })
1722
.demand(1)
1823
.argv;
1924

2025
var appFile = path.resolve(argv._[0]);
2126
var outputFile = argv._[1];
2227

23-
console.error('Loading LoopBack app %j', appFile);
28+
g.error('Loading {{LoopBack}} app %j', appFile);
2429
var app = require(appFile);
2530
assertLoopBackVersion();
2631

@@ -34,15 +39,15 @@ function runGenerator() {
3439
var ngModuleName = argv['module-name'] || 'lbServices';
3540
var apiUrl = argv['url'] || app.get('restApiRoot') || '/api';
3641

37-
console.error('Generating %j for the API endpoint %j', ngModuleName, apiUrl);
42+
g.error('Generating %j for the API endpoint %j', ngModuleName, apiUrl);
3843
var result = generator.services(app, ngModuleName, apiUrl);
3944

4045
if (outputFile) {
4146
outputFile = path.resolve(outputFile);
42-
console.error('Saving the generated services source to %j', outputFile);
47+
g.error('Saving the generated services source to %j', outputFile);
4348
fs.writeFileSync(outputFile, result);
4449
} else {
45-
console.error('Dumping to stdout');
50+
g.error('Dumping to {{stdout}}');
4651
process.stdout.write(result);
4752
}
4853

@@ -67,10 +72,10 @@ function assertLoopBackVersion() {
6772
var loopback = Module._load('loopback', Module._cache[appFile]);
6873

6974
if (semver.lt(loopback.version, '1.6.0')) {
70-
console.error(
71-
'\nThe code generator does not support applications based\n' +
72-
'on LoopBack versions older than 1.6.0. Please upgrade your\n' +
73-
'project to a recent version of LoopBack and run this tool again.\n');
75+
g.error('\n' +
76+
'The code generator does not support applications based on\n' +
77+
'{{LoopBack}} versions older than 1.6.0. Please upgrade your project\n' +
78+
'to a recent version of {{LoopBack}} and run this tool again.\n');
7479
process.exit(1);
7580
}
7681
}

intl/en/messages.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"03bb755ed8213986b1862be937b296bb": "The name for generated {{Angular}} module.",
3+
"25eecfaa310e55ace4ef6eba593ba32e": "Generating {0} for the API endpoint {1}",
4+
"3669f5dd8a727a4f4247d7ad86993e0c": "\nThe code generator does not support applications based on\n{{LoopBack}} versions older than 1.6.0. Please upgrade your project\nto a recent version of {{LoopBack}} and run this tool again.\n",
5+
"af39e85bbd74a37c9a8beec4268564bd": "Generate {{Angular $resource}} services for your {{LoopBack}} application.\nUsage:\n $0 {{[options] server/app.js [client/js/lb-services.js]}}",
6+
"dbef1e1c2cc9f52ae9aacca33e9d92c2": "Saving the generated services source to {0}",
7+
"dff77762368d4e45c34a01e661ad2c06": "Loading {{LoopBack}} app {0}",
8+
"efc6bce92bcb061e3e354a888c7bd76a": "Dumping to {{stdout}}",
9+
"fc1c9755ca71e88d7aaa4be225d07bc8": "URL of the REST API end-point"
10+
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "2.0.1",
44
"description": "CLI tools for auto-generating Angular $resource services for LoopBack",
55
"bin": {
6-
"lb-ng": "bin/lb-ng"
6+
"lb-ng": "bin/lb-ng.js"
77
},
88
"scripts": {
99
"pretest": "jshint .",
@@ -33,7 +33,8 @@
3333
"dependencies": {
3434
"loopback-sdk-angular": "^1.1.1",
3535
"optimist": "^0.6.1",
36-
"semver": "^2.2.1"
36+
"semver": "^2.2.1",
37+
"strong-globalize": "^2.6.0"
3738
},
3839
"devDependencies": {
3940
"bluebird": "^1.2.1",

0 commit comments

Comments
 (0)