Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add i18n client #121

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module.exports = class extends AppGenerator {
validateJava() {},

customSettings() {
this.skipI18n = true;
this.skipI18n = false;
this.testFrameworks = [];
this.enableTranslation = false;
}
Expand Down
13 changes: 7 additions & 6 deletions generators/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ module.exports = class extends ClientGenerator {
}

get default() {
const defaultPhaseFromJHipster = super._default();
const defaultNodeClientPhaseSteps = {
// disable languages
composeLanguages() {}
};
return Object.assign(defaultPhaseFromJHipster, defaultNodeClientPhaseSteps);
// const defaultPhaseFromJHipster = super._default();
// const defaultNodeClientPhaseSteps = {
// // disable languages
// composeLanguages() {}
// };
// return Object.assign(defaultPhaseFromJHipster, defaultNodeClientPhaseSteps);
return super._default();
}

get writing() {
Expand Down
24 changes: 24 additions & 0 deletions generators/languages/USAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Description:
Select languages from a list of available languages. The i18n files will be copied to the /webapp/i18n folder.

Example:
jhipster languages

This will create for each selected language:
/webapp/i18n/{lang}/global.json
/webapp/i18n/{lang}/activate.json
/webapp/i18n/{lang}/audits.json
/webapp/i18n/{lang}/configuration.json
/webapp/i18n/{lang}/error.json
/webapp/i18n/{lang}/gateway.json
/webapp/i18n/{lang}/health.json
/webapp/i18n/{lang}/home.json
/webapp/i18n/{lang}/login.json
/webapp/i18n/{lang}/logs.json
/webapp/i18n/{lang}/metrics.json
/webapp/i18n/{lang}/password.json
/webapp/i18n/{lang}/register.json
/webapp/i18n/{lang}/reset.json
/webapp/i18n/{lang}/sessions.json
/webapp/i18n/{lang}/settings.json
/webapp/i18n/{lang}/user-management.json
126 changes: 126 additions & 0 deletions generators/languages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/* eslint-disable consistent-return */
const chalk = require('chalk');
const LanguagesGenerator = require('generator-jhipster/generators/languages');

module.exports = class extends LanguagesGenerator {
constructor(args, opts) {
super(args, { fromBlueprint: true, ...opts }); // fromBlueprint variable is important

const jhContext = (this.jhipsterContext = this.options.jhipsterContext);

if (!jhContext) {
this.error(`This is a JHipster blueprint and should be used only like ${chalk.yellow('jhipster --blueprint myown')}`);
}

this.configOptions = jhContext.configOptions || {};
}

get initializing() {
/**
* Any method beginning with _ can be reused from the superclass `LanguagesGenerator`
*
* There are multiple ways to customize a phase from JHipster.
*
* 1. Let JHipster handle a phase, blueprint doesnt override anything.
* ```
* return super._initializing();
* ```
*
* 2. Override the entire phase, this is when the blueprint takes control of a phase
* ```
* return {
* myCustomInitPhaseStep() {
* // Do all your stuff here
* },
* myAnotherCustomInitPhaseStep(){
* // Do all your stuff here
* }
* };
* ```
*
* 3. Partially override a phase, this is when the blueprint gets the phase from JHipster and customizes it.
* ```
* const phaseFromJHipster = super._initializing();
* const myCustomPhaseSteps = {
* displayLogo() {
* // override the displayLogo method from the _initializing phase of JHipster
* },
* myCustomInitPhaseStep() {
* // Do all your stuff here
* },
* }
* return Object.assign(phaseFromJHipster, myCustomPhaseSteps);
* ```
*/
// Here we are not overriding this phase and hence its being handled by JHipster
return super._initializing();
}

get prompting() {
// Here we are not overriding this phase and hence its being handled by JHipster
return super._prompting();
}

get configuring() {
// Here we are not overriding this phase and hence its being handled by JHipster
return super._configuring();
}

get default() {
const phaseFromJHipster = super._default();
const myCustomPhaseSteps = {
getSharedConfigOptions() {
if (this.configOptions.applicationType) {
this.applicationType = this.configOptions.applicationType;
}
if (this.configOptions.baseName) {
this.baseName = this.configOptions.baseName;
}
if (this.configOptions.websocket !== undefined) {
this.websocket = this.configOptions.websocket;
}
if (this.configOptions.databaseType) {
this.databaseType = this.configOptions.databaseType;
}
if (this.configOptions.searchEngine !== undefined) {
this.searchEngine = this.configOptions.searchEngine;
}
if (this.configOptions.messageBroker !== undefined) {
this.messageBroker = this.configOptions.messageBroker;
}
if (this.configOptions.enableTranslation) {
this.enableTranslation = this.configOptions.enableTranslation;
}
if (this.configOptions.nativeLanguage) {
this.nativeLanguage = this.configOptions.nativeLanguage;
}
if (this.configOptions.skipClient) {
this.skipClient = this.configOptions.skipClient;
}

// disable languages
this.skipServer = true;

if (this.configOptions.clientFramework) {
this.clientFramework = this.configOptions.clientFramework;
}
}
};
return Object.assign(phaseFromJHipster, myCustomPhaseSteps);
}

get writing() {
// Here we are not overriding this phase and hence its being handled by JHipster
return super._writing();
}

get install() {
// Here we are not overriding this phase and hence its being handled by JHipster
return super._install();
}

get end() {
// Here we are not overriding this phase and hence its being handled by JHipster
return super._end();
}
};
Loading