Skip to content

Commit

Permalink
Adjusts to languages generator. (#15952)
Browse files Browse the repository at this point in the history
* Make languages generator reproducible

* Don't write messages_en.properties when translation is enabled.

* Move languages needles to postWriting priority
  • Loading branch information
mshima authored Aug 13, 2021
1 parent 85f6365 commit e14dae5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
16 changes: 14 additions & 2 deletions generators/languages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,18 @@ module.exports = class extends BaseBlueprintGenerator {
statistics.sendSubGenEvent('languages/language', language);
});
},

...super._missingPostWriting(),
};
}

get writing() {
if (useBlueprints) return;
return this._writing();
}

_postWriting() {
return {
write() {
if (!this.skipClient) {
this.updateLanguagesInDayjsConfiguation(this.languages);
Expand Down Expand Up @@ -272,8 +284,8 @@ module.exports = class extends BaseBlueprintGenerator {
};
}

get writing() {
get postWriting() {
if (useBlueprints) return;
return this._writing();
return this._postWriting();
}
};
2 changes: 1 addition & 1 deletion generators/languages/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function askI18n() {
name: 'nativeLanguage',
message: 'Please choose the native language of the application',
choices: () => this.getAllSupportedLanguageOptions(),
default: () => detectLanguage(),
default: () => (this.options.reproducible ? 'en' : detectLanguage()),
store: true,
},
],
Expand Down
6 changes: 5 additions & 1 deletion generators/server/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -1682,9 +1682,13 @@ const serverFiles = {
templates: [
/* User management java test files */
'templates/mail/testEmail.html',
'i18n/messages_en.properties',
],
},
{
condition: generator => !generator.skipUserManagement && !generator.enableTranslation,
path: SERVER_TEST_RES_DIR,
templates: ['i18n/messages_en.properties'],
},
{
condition: generator => !generator.skipUserManagement,
path: SERVER_TEST_SRC_DIR,
Expand Down
4 changes: 4 additions & 0 deletions test/blueprint/languages-blueprint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ const mockBlueprintSubGen = class extends LanguagesGenerator {
get writing() {
return super._writing();
}

get postWriting() {
return super._postWriting();
}
};

describe('JHipster languages generator with blueprint', () => {
Expand Down
4 changes: 4 additions & 0 deletions test/needle-api/needle-client-i18n.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ const mockBlueprintSubGen = class extends LanguagesGenerator {
};
return { ...phaseFromJHipster, ...customPhaseSteps };
}

get postWriting() {
return super._postWriting();
}
};

describe('needle API i18n: JHipster language generator with blueprint', () => {
Expand Down

0 comments on commit e14dae5

Please sign in to comment.