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

write translation files even for entity only generation #24259

Merged
merged 3 commits into from
Nov 16, 2023
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
2 changes: 1 addition & 1 deletion generators/base-core/generator.mts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default class CoreGenerator extends YeomanGenerator<JHipsterGeneratorOpti
*/
getTaskNames(): string[] {
let priorities = super.getTaskNames();
if (this.options.skipPriorities) {
if (!this.features.disableSkipPriorities && this.options.skipPriorities) {
// Make sure yeoman-generator will not throw on empty tasks due to filtered priorities.
this.customLifecycle = priorities.length > 0;
priorities = priorities.filter(priorityName => !this.options.skipPriorities!.includes(priorityName));
Expand Down
4 changes: 4 additions & 0 deletions generators/base/api.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export type JHipsterGeneratorFeatures = BaseFeatures & {
jhipster7Migration?: boolean;
sbsBlueprint?: boolean;
checkBlueprint?: boolean;
/**
* Disable skipPriorities flag.
*/
disableSkipPriorities?: boolean;
/**
* Compose with bootstrap generator.
*
Expand Down
90 changes: 90 additions & 0 deletions generators/entities/__snapshots__/generator.spec.mts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,60 @@ exports[`generator - entities regenerating all entities should match snapshot 1`
"src/main/webapp/app/entities/skip/update/skip-update.component.ts": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/activate.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/bar.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/configuration.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/error.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/foo.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/global.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/health.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/home.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/login.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/logs.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/metrics.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/password.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/register.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/reset.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/sessions.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/settings.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/skip.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/user-management.json": {
"stateCleared": "modified",
},
"src/test/java/com/mycompany/myapp/domain/BarTest.java": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -535,12 +580,57 @@ exports[`generator - entities regenerating some entities should match snapshot 1
"src/main/webapp/app/entities/foo/update/foo-update.component.ts": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/activate.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/bar.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/configuration.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/error.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/foo.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/global.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/health.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/home.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/login.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/logs.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/metrics.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/password.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/register.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/reset.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/sessions.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/settings.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/user-management.json": {
"stateCleared": "modified",
},
"src/test/java/com/mycompany/myapp/domain/BarTest.java": {
"stateCleared": "modified",
},
Expand Down
17 changes: 16 additions & 1 deletion generators/languages/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { updateLanguagesTask as updateLanguagesInJava } from '../server/support/
import { SERVER_MAIN_RES_DIR, SERVER_TEST_RES_DIR } from '../generator-constants.mjs';
import command from './command.mjs';
import { QUEUES } from '../base-application/priorities.mjs';
import { PRIORITY_NAMES } from '../base/priorities.mjs';

const { startCase } = _;

Expand Down Expand Up @@ -75,6 +76,17 @@ export default class LanguagesGenerator extends BaseApplicationGenerator {
if (!this.delegateToBlueprint) {
await this.dependsOnJHipster(GENERATOR_BOOTSTRAP_APPLICATION);
}

if (
!this.jhipsterConfigWithDefaults.skipClient &&
this.jhipsterConfigWithDefaults.clientFramework !== 'no' &&
(!this.jhipsterConfig.enableTranslation || this.jhipsterConfigWithDefaults.clientFramework === 'angular')
) {
// We must write languages files for translation process for entities only generation.
// Angular frontend uses translation files even if enableTranslation is enabled.
// As side effect, with angular frontends, translation files will be written for nativeLanguage for entity only generation.
this.setFeatures({ disableSkipPriorities: true });
}
}

// Public API method used by the getter and also by Blueprints
Expand Down Expand Up @@ -268,7 +280,8 @@ export default class LanguagesGenerator extends BaseApplicationGenerator {
if (
!application.enableTranslation ||
application.skipServer ||
(!application.backendTypeSpringBoot && !this.writeJavaLanguageFiles)
(!application.backendTypeSpringBoot && !this.writeJavaLanguageFiles) ||
this.options.skipPriorities?.includes?.(PRIORITY_NAMES.POST_WRITING)
)
return;
await Promise.all(
Expand Down Expand Up @@ -323,6 +336,8 @@ export default class LanguagesGenerator extends BaseApplicationGenerator {
get postWriting() {
return this.asPostWritingTaskGroup({
write({ application, control }) {
if (this.options.skipPriorities?.includes?.(PRIORITY_NAMES.POST_WRITING)) return;

if (application.enableTranslation && !application.skipClient) {
if (application.clientFrameworkAngular) {
updateLanguagesInAngularTask.call(this, { application, control });
Expand Down