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 @@ -28,3 +28,6 @@ temp/
test/sandbox
test/.pkgcache/
.pkgcache/
!intl/
intl/*
!intl/en/
24 changes: 14 additions & 10 deletions acl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
// License text available at https://opensource.org/licenses/MIT

'use strict';

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

var yeoman = require('yeoman-generator');
var async = require('async');

Expand Down Expand Up @@ -59,7 +63,7 @@ module.exports = yeoman.Base.extend({
var prompts = [
{
name: 'model',
message: 'Select the model to apply the ACL entry to:',
message: g.f('Select the model to apply the ACL entry to:'),
type: 'list',
default: 0,
choices: modelChoices,
Expand All @@ -80,34 +84,34 @@ module.exports = yeoman.Base.extend({
var prompts = [
{
name: 'scope',
message: 'Select the ACL scope:',
message: g.f('Select the ACL scope:'),
type: 'list',
default: 'all',
choices: [
{name: 'All methods and properties', value: 'all'},
{name: 'A single method', value: 'method'},
{name: g.f('All methods and properties'), value: 'all'},
{name: g.f('A single method'), value: 'method'},
/* not supported by loopback yet
{ name: 'A single property', value: 'property' }
*/
],
},
{
name: 'property',
message: 'Enter the method name',
message: g.f('Enter the method name'),
when: function(answers) {
return answers.scope === 'method';
},
},
{
name: 'property',
message: 'Enter the property name',
message: g.f('Enter the property name'),
when: function(answers) {
return answers.scope === 'property';
},
},
{
name: 'accessType',
message: 'Select the access type:',
message: g.f('Select the access type:'),
type: 'list',
default: '*',
when: function(answers) {
Expand All @@ -117,22 +121,22 @@ module.exports = yeoman.Base.extend({
},
{
name: 'role',
message: 'Select the role',
message: g.f('Select the role'),
type: 'list',
default: '$everyone',
choices: this.roleValues.concat(['other']),
},
{
name: 'customRole',
message:
'Enter the role name:',
g.f('Enter the role name:'),
when: function(answers) {
return answers.role === 'other';
},
},
{
name: 'permission',
message: 'Select the permission to apply',
message: g.f('Select the permission to apply'),
type: 'list',
choices: this.permissionValues,
},
Expand Down
49 changes: 27 additions & 22 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
// License text available at https://opensource.org/licenses/MIT

'use strict';

var path = require('path');
var SG = require('strong-globalize');
SG.SetRootDir(path.join(__dirname, '..'));
var g = SG();

var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var chalk = require('chalk');
var workspace = require('loopback-workspace');
var Workspace = workspace.models.Workspace;

var fs = require('fs');
var path = require('path');
var util = require('util');

var actions = require('../lib/actions');
var helpers = require('../lib/helpers');
Expand All @@ -24,34 +28,35 @@ module.exports = yeoman.Base.extend({
yeoman.Base.apply(this, arguments);

this.argument('name', {
desc: 'Name of the application to scaffold.',
desc: g.f('Name of the application to scaffold.'),
required: false,
type: String,
});

this.option('skip-install', {
desc: 'Do not install npm dependencies.',
desc: g.f('Do not install npm dependencies.'),
type: Boolean,
});

this.option('skip-next-steps', {
desc: 'Do not print "next steps" info',
desc: g.f('Do not print "next steps" info'),
type: Boolean,
});

this.option('explorer', {
desc: 'Add Loopback Explorer to the project (true by default)',
desc: g.f('Add {{Loopback Explorer }}to the project ({{true}} ' +
'by default)'),
type: Boolean,
});
},

greet: function() {
this.log(yosay('Let\'s create a LoopBack application!'));
this.log(yosay(g.f('Let\'s create a {{LoopBack}} application!')));
},

help: function() {
var msgs = [helpers.customHelp(this)];
msgs.push('Available generators: \n\n ');
msgs.push(g.f('Available generators: \n\n '));
msgs.push(Object.keys(this.options.env.getGeneratorsMeta())
.filter(function(name) {
return name.indexOf('loopback:') !== -1;
Expand Down Expand Up @@ -84,7 +89,7 @@ module.exports = yeoman.Base.extend({
if (err) return done(err);
this.templates = list.map(function(t) {
return {
name: util.format('%s (%s)', t.name, t.description),
name: g.f('%s (%s)', t.name, t.description),
value: t.name,
};
});
Expand Down Expand Up @@ -119,7 +124,7 @@ module.exports = yeoman.Base.extend({
var prompts = [
{
name: 'appname',
message: 'What\'s the name of your application?',
message: g.f('What\'s the name of your application?'),
default: name,
validate: validateAppName,
},
Expand All @@ -135,7 +140,7 @@ module.exports = yeoman.Base.extend({
askForTemplate: function() {
var prompts = [{
name: 'wsTemplate',
message: 'What kind of application do you have in mind?',
message: g.f('What kind of application do you have in mind?'),
type: 'list',
default: this.defaultTemplate,
choices: this.templates,
Expand Down Expand Up @@ -167,7 +172,7 @@ module.exports = yeoman.Base.extend({
askForLBVersion: function() {
var prompts = [{
name: 'loopbackVersion',
message: 'Which version of LoopBack would you like to use?',
message: 'Which version of {{LoopBack}} would you like to use?',
type: 'list',
default: '2.x',
choices: this.availableLBVersions,
Expand All @@ -187,7 +192,7 @@ module.exports = yeoman.Base.extend({
if (err) {
cb();
} else {
cb(new Error('The generator must be run in an empty directory.'));
cb(new Error(g.f('The generator must be run in an empty directory.')));
}
});
},
Expand All @@ -211,7 +216,7 @@ module.exports = yeoman.Base.extend({
},

generateYoRc: function() {
this.log('Generating .yo-rc.json');
this.log(g.f('Generating {{.yo-rc.json}}'));
this.config.save();
},

Expand All @@ -226,27 +231,27 @@ module.exports = yeoman.Base.extend({
this.log();
}

this.log('Next steps:');
this.log(g.f('Next steps:'));
this.log();
if (this.dir && this.dir !== '.') {
this.log(' Change directory to your app');
this.log(g.f(' Change directory to your app'));
this.log(chalk.green(' $ cd ' + this.dir));
this.log();
}
if (cmd === 'apic') {
this.log(' Run API Designer to create, test, and publish your' +
' application');
this.log(g.f(' Run {{API Designer}} to create, test, and publish your' +
' application'));
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.

And maybe wrap {{API Designer}} ?

this.log(chalk.green(' $ apic edit'));
this.log();
} else {
this.log(' Create a model in your app');
this.log(g.f(' Create a model in your app'));
this.log(chalk.green(' $ ' + cmd + ' loopback:model'));
this.log();
this.log(
' Compose your API, run, deploy, profile, and monitor it with Arc');
this.log(g.f(
' Compose your API, run, deploy, profile, and monitor it with Arc'));
this.log(chalk.green(' $ slc arc'));
this.log();
this.log(' Run the app');
this.log(g.f(' Run the app'));
this.log(chalk.green(' $ node .'));
this.log();
}
Expand Down
14 changes: 10 additions & 4 deletions boot-script/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
// License text available at https://opensource.org/licenses/MIT

'use strict';

var SG = require('strong-globalize');
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.

Minor comment: no need to have require('path') before require('strong-globalize)`

var g = SG();

var helpers = require('../lib/helpers');
var path = require('path');
var yeoman = require('yeoman-generator');
Expand All @@ -15,7 +19,7 @@ module.exports = yeoman.Base.extend({
yeoman.Base.apply(this, arguments);

this.argument('name', {
desc: 'Name of the boot script to create.',
desc: g.f('Name of the boot script to create.'),
required: false,
optional: true,
type: String,
Expand All @@ -33,7 +37,7 @@ module.exports = yeoman.Base.extend({

var question = {
name: 'name',
message: 'Enter the script name (without `.js`):',
message: g.f('Enter the script name (without {{`.js`}}):'),
default: this.name,
validate: validateRequiredName,
};
Expand All @@ -47,9 +51,11 @@ module.exports = yeoman.Base.extend({
askForType: function() {
var question = {
name: 'type',
message: 'What type of boot script do you want to generate?',
message: g.f('What type of boot script do you want to generate?'),
type: 'list',
choices: ['async', 'sync'],
choices: [
{name: g.f('async'), value: 'async'},
{name: g.f('sync'), value: 'sync'}],
default: 'async',
};

Expand Down
21 changes: 13 additions & 8 deletions datasource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
// License text available at https://opensource.org/licenses/MIT

'use strict';

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

var chalk = require('chalk');
var yeoman = require('yeoman-generator');
var extend = require('util')._extend;
Expand All @@ -29,7 +33,7 @@ module.exports = yeoman.Base.extend({
yeoman.Base.apply(this, arguments);

this.argument('name', {
desc: 'Name of the data-source to create.',
desc: g.f('Name of the data-source to create.'),
required: false,
type: String,
});
Expand All @@ -48,8 +52,8 @@ module.exports = yeoman.Base.extend({

this.listOfAvailableConnectors = list.map(function(c) {
var support = c.supportedByStrongLoop ?
' (supported by StrongLoop)' :
' (provided by community)';
g.f(' (supported by StrongLoop)') :
g.f(' (provided by community)');
return {
name: c.description + support,
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.

A minor globalization issue here is the concatenation c.description + support Text concatenation with + operator of multiple strings may compose a right English, but not usually the case in other languages.

This particular case is not a problem. String concatenation in code is one of the typical globalization bugs.

value: c.name,
Expand All @@ -74,7 +78,7 @@ module.exports = yeoman.Base.extend({
var prompts = [
{
name: 'name',
message: 'Enter the data-source name:',
message: g.f('Enter the data-source name:'),
default: this.name,
validate: validateRequiredName,
},
Expand All @@ -93,15 +97,16 @@ module.exports = yeoman.Base.extend({
var prompts = [
{
name: 'connector',
message: 'Select the connector for ' + displayName + ':',
message: g.f('Select the connector for %s:', displayName),
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.

Yup, this is the case of string concatenation globalization bug and the right solution.

type: 'list',
default: 'memory',
choices: connectorChoices,
},
{
name: 'customConnector',
message:
'Enter the connector name without the loopback-connector- prefix:',
g.f('Enter the connector name without the ' +
'{{loopback-connector-}} prefix:'),
validate: validateRequiredName,
when: function(answers) {
return answers.connector === 'other';
Expand Down Expand Up @@ -166,7 +171,7 @@ module.exports = yeoman.Base.extend({
if (!prompts.length && !warnings.length)
return;

this.log('Connector-specific configuration:');
this.log(g.f('Connector-specific configuration:'));
if (!prompts.length) return reportWarnings();

return this.prompt(prompts).then(function(props) {
Expand Down Expand Up @@ -210,7 +215,7 @@ module.exports = yeoman.Base.extend({
var prompts = [
{
name: 'installConnector',
message: 'Install ' + npmModule,
message: g.f('Install %s', npmModule),
Copy link
Copy Markdown
Contributor

@Setogit Setogit Jul 1, 2016

Choose a reason for hiding this comment

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

👍

type: 'confirm',
default: true,
},
Expand Down
8 changes: 6 additions & 2 deletions export-api-def/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
// License text available at https://opensource.org/licenses/MIT

'use strict';
var fs = require('fs');

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

var fs = require('fs');
var yeoman = require('yeoman-generator');
var helpers = require('../lib/helpers');
var apiGenerator = require('loopback-api-definition');
Expand All @@ -20,7 +24,7 @@ module.exports = yeoman.Base.extend({
this.option('output', {
type: String,
alias: 'o',
desc: 'Name/Full path to the output file.',
desc: g.f('Name/Full path to the output file.'),
defaults: '',
});
},
Expand Down
Loading