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

convert entities to new translate api #25693

Merged
merged 1 commit into from
Apr 1, 2024
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/angular/support/translate-angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const pipeEnumTranslation = (
}
const { value, fallback } = parsedInterpolate;
if (enableTranslation) {
return `${prefix}{{ \`${key}.\${value}\` | translate }}${suffix}`;
return `${prefix}{{ '${key}.' + ${value} | translate }}${suffix}`;
}

const translatedValue = `{{ ${JSON.stringify(getTranslationValue(getWebappTranslation, key))}[${value}]${fallback ? ` ?? ${fallback}` : ''} }}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@if (<%= entityInstance %>) {
<form name="deleteForm" (ngSubmit)="confirmDelete(<%= entityInstance %>.<%= primaryKey.name %>!)">
<div class="modal-header">
<h4 class="modal-title" data-cy="<%= entityInstance %>DeleteDialogHeading" <%= jhiPrefix %>Translate="entity.delete.title">__jhiTransformTranslate__('entity.delete.title')</h4>
<h4 class="modal-title" data-cy="<%= entityInstance %>DeleteDialogHeading">__jhiTranslateTag__('entity.delete.title')</h4>

<span class="btn btn-close" data-dismiss="modal" aria-hidden="true"
(click)="cancel()"></span>
Expand All @@ -32,11 +32,11 @@

<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="cancel()">
<fa-icon icon="ban"></fa-icon>&nbsp;<span <%= jhiPrefix %>Translate="entity.action.cancel">__jhiTransformTranslate__('entity.action.cancel')</span>
<fa-icon icon="ban"></fa-icon>&nbsp;<span>__jhiTranslateTag__('entity.action.cancel')</span>
</button>

<button id="<%= jhiPrefixDashed %>-confirm-delete-<%= entityInstance %>" data-cy="entityConfirmDeleteButton" type="submit" class="btn btn-danger">
<fa-icon icon="times"></fa-icon>&nbsp;<span <%= jhiPrefix %>Translate="entity.action.delete">__jhiTransformTranslate__('entity.action.delete')</span>
<fa-icon icon="times"></fa-icon>&nbsp;<span>__jhiTranslateTag__('entity.action.delete')</span>
</button>
</div>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="col-8">
@if (<%= entityInstance %>) {
<div>
<h2 data-cy="<%= entityInstance %>DetailsHeading"><span <%= jhiPrefix %>Translate="<%= i18nKeyPrefix %>.detail.title">__jhiTransformTranslate__('<%- i18nKeyPrefix %>.detail.title')</span></h2>
<h2 data-cy="<%= entityInstance %>DetailsHeading"><span>__jhiTranslateTag__('<%- i18nKeyPrefix %>.detail.title')</span></h2>

<hr>

Expand All @@ -33,11 +33,11 @@
const fieldName = field.fieldName;
const fieldType = field.fieldType;
_%>
<dt><span <%= jhiPrefix %>Translate="<%= field.fieldTranslationKey %>"<% if (field.documentation) { if (enableTranslation) { %> [ngbTooltip]="'<%= i18nKeyPrefix %>.help.<%= fieldName %>' | translate"<% } else { %> ngbTooltip="<%= field.documentation %>"<% } } %>>__jhiTransformTranslate__('<%- field.fieldTranslationKey %>')</span></dt>
<dt><span<% if (field.documentation) { if (enableTranslation) { %> [ngbTooltip]="'<%= i18nKeyPrefix %>.help.<%= fieldName %>' | translate"<% } else { %> ngbTooltip="<%= field.documentation %>"<% } } %>>__jhiTranslateTag__('<%- field.fieldTranslationKey %>')</span></dt>
<dd>
<%_ if (field.fieldIsEnum) { _%>
<%# TODO: import enum and use its key as label _%>
<span <%= jhiPrefix %>Translate="{{ '<%= frontendAppName %>.<%= fieldType %>.' + <%= entityInstance %>.<%= fieldName %> }}">{{ <%= entityInstance %>.<%= fieldName %> }}</span>
<span>__jhiTranslateTagEnum__('<%= frontendAppName %>.<%= fieldType %>', { "value": "<%= entityInstance %>.<%= fieldName %> ?? 'null'" })</span>
<%_ } else if (field.fieldTypeBinary && field.blobContentTypeImage) { _%>
@if (<%= entityInstance %>.<%= fieldName %>) {
<div>
Expand All @@ -50,7 +50,7 @@ _%>
<%_ } else if (field.fieldTypeBinary && field.blobContentTypeAny) { _%>
@if (<%= entityInstance %>.<%= fieldName %>) {
<div>
<a (click)="openFile(<%= entityInstance %>.<%= fieldName %>, <%= entityInstance %>.<%= fieldName %>ContentType)" <%= jhiPrefix %>Translate="entity.action.open">__jhiTransformTranslate__('entity.action.open')</a>
<a (click)="openFile(<%= entityInstance %>.<%= fieldName %>, <%= entityInstance %>.<%= fieldName %>ContentType)">__jhiTranslateTag__('entity.action.open')</a>
{{ <%= entityInstance %>.<%= fieldName %>ContentType }}, {{ byteSize(<%= entityInstance %>.<%= fieldName %>) }}
</div>
}
Expand All @@ -75,7 +75,7 @@ for (const relationship of relationships.filter(rel => !rel.otherEntityIsEmbedde
const otherEntityField = relationship.otherEntityField;
if (persistableRelationship) {
_%>
<dt><span <%= jhiPrefix %>Translate="<%= i18nKeyPrefix %>.<%= relationshipName %>">__jhiTransformTranslate__('<%- i18nKeyPrefix %>.<%- relationshipName %>')</span></dt>
<dt><span>__jhiTranslateTag__('<%- i18nKeyPrefix %>.<%- relationshipName %>')</span></dt>
<dd>
<%_ if (relationship.otherEntityUser) { _%>
<%_ if (relationship.collection) { _%>
Expand Down Expand Up @@ -113,14 +113,14 @@ _%>
(click)="previousState()"
class="btn btn-info"
data-cy="entityDetailsBackButton">
<fa-icon icon="arrow-left"></fa-icon>&nbsp;<span <%= jhiPrefix %>Translate="entity.action.back">__jhiTransformTranslate__('entity.action.back')</span>
<fa-icon icon="arrow-left"></fa-icon>&nbsp;<span>__jhiTranslateTag__('entity.action.back')</span>
</button>
<%_ if (!readOnly && updatableEntity) { _%>

<button type="button"
[routerLink]="['/<%= entityPage %>', <%= entityInstance %>.<%= primaryKey.name %>, 'edit']"
class="btn btn-primary">
<fa-icon icon="pencil-alt"></fa-icon>&nbsp;<span <%= jhiPrefix %>Translate="entity.action.edit">__jhiTransformTranslate__('entity.action.edit')</span>
<fa-icon icon="pencil-alt"></fa-icon>&nbsp;<span>__jhiTranslateTag__('entity.action.edit')</span>
</button>
<%_ } _%>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
-%>
<div>
<h2 id="page-heading" data-cy="<%= entityClass %>Heading">
<span <%= jhiPrefix %>Translate="<%= i18nKeyPrefix %>.home.title">__jhiTransformTranslate__('<%- i18nKeyPrefix %>.home.title')</span>
<span>__jhiTranslateTag__('<%- i18nKeyPrefix %>.home.title')</span>

<div class="d-flex justify-content-end">
<button class="btn btn-info me-2" (click)="load()" [disabled]="isLoading">
<fa-icon icon="sync" [spin]="isLoading"></fa-icon>
<span <%= jhiPrefix %>Translate="<%= i18nKeyPrefix %>.home.refreshListLabel">__jhiTransformTranslate__('<%- i18nKeyPrefix %>.home.refreshListLabel')</span>
<span>__jhiTranslateTag__('<%- i18nKeyPrefix %>.home.refreshListLabel')</span>
</button>
<%_ if (!readOnly) { _%>

<button id="jh-create-entity" data-cy="entityCreateButton" class="btn btn-primary jh-create-entity create-<%= entityUrl %>" [routerLink]="['/<%= entityPage %>/new']">
<fa-icon icon="plus"></fa-icon>
<span <% if (searchEngineAny) { %>class="hidden-sm-down" <% } %> <%= jhiPrefix %>Translate="<%= i18nKeyPrefix %>.home.createLabel">__jhiTransformTranslate__('<%- i18nKeyPrefix %>.home.createLabel')</span>
<span <% if (searchEngineAny) { %>class="hidden-sm-down" <% } %>>__jhiTranslateTag__('<%- i18nKeyPrefix %>.home.createLabel')</span>
</button>
<%_ } _%>
</div>
Expand All @@ -43,8 +43,8 @@
<form name="searchForm" class="row row-cols-sm-auto align-items-center">
<div class="col-sm-12">
<div class="input-group w-100 mt-3">
<label class="visually-hidden" for="currentSearch" <%= jhiPrefix %>Translate="<%= i18nKeyPrefix %>.home.search">__jhiTransformTranslate__('<%- i18nKeyPrefix %>.home.search')</label>
<input type="text" class="form-control" [(ngModel)]="currentSearch" id="currentSearch" name="currentSearch" placeholder="<% if (enableTranslation) { %>{{ '<%= i18nKeyPrefix %>.home.search' | translate }}<% } else { %>Query<% } %>">
<label class="visually-hidden" for="currentSearch">__jhiTranslateTag__('<%- i18nKeyPrefix %>.home.search')</label>
<input type="text" class="form-control" [(ngModel)]="currentSearch" id="currentSearch" name="currentSearch" placeholder="__jhiTranslatePipe__('<%= i18nKeyPrefix %>.home.search')">

<button class="btn btn-info" (click)="search(currentSearch)">
<fa-icon icon="search"></fa-icon>
Expand All @@ -66,7 +66,7 @@

@if (<%= entityInstancePlural %>?.length === 0) {
<div class="alert alert-warning" id="no-result">
<span <%= jhiPrefix %>Translate="<%= i18nKeyPrefix %>.home.notFound">__jhiTransformTranslate__('<%- i18nKeyPrefix %>.home.notFound')</span>
<span>__jhiTranslateTag__('<%- i18nKeyPrefix %>.home.notFound')</span>
</div>
}

Expand All @@ -78,7 +78,7 @@
<%_ for (const field of fields.filter(field => !field.hidden)) { _%>
<th scope="col" <%= jhiPrefix %>SortBy="<%= field.fieldName %>">
<div class="d-flex">
<span <%= jhiPrefix %>Translate="<%= field.fieldTranslationKey %>">__jhiTransformTranslate__('<%- field.fieldTranslationKey %>')</span>
<span>__jhiTranslateTag__('<%- field.fieldTranslationKey %>')</span>
<%_ if (!field.transient) { _%>
<% if (searchEngineAny && !field.fieldTypeBoolean && !field.fieldTypeNumeric && !field.fieldTypeTemporal) { %>@if (!currentSearch) {<% } %>
<fa-icon class="p-1" icon="sort"></fa-icon>
Expand All @@ -93,7 +93,7 @@
_%>
<th scope="col" <%= jhiPrefix %>SortBy="<%= relationship.relationshipName + (fieldName) %>">
<div class="d-flex">
<span <%= jhiPrefix %>Translate="<%= `${i18nKeyPrefix}.${relationship.relationshipName}` %>">__jhiTransformTranslate__('<%- i18nKeyPrefix %>.<%- relationship.relationshipName %>')</span>
<span>__jhiTranslateTag__('<%- i18nKeyPrefix %>.<%- relationship.relationshipName %>')</span>
<fa-icon class="p-1" icon="sort"></fa-icon>
</div>
</th>
Expand Down Expand Up @@ -123,13 +123,13 @@ _%>
<%_ } else if (field.fieldTypeBinary && field.blobContentTypeAny) { _%>
<td>
@if (<%= entityInstance %>.<%= fieldName %>) {
<a (click)="openFile(<%= entityInstance %>.<%= fieldName %>, <%= entityInstance %>.<%= fieldName %>ContentType)" <%= jhiPrefix %>Translate="entity.action.open">__jhiTransformTranslate__('entity.action.open')</a>
<a (click)="openFile(<%= entityInstance %>.<%= fieldName %>, <%= entityInstance %>.<%= fieldName %>ContentType)">__jhiTranslateTag__('entity.action.open')</a>
<span>{{ <%= entityInstance %>.<%= fieldName %>ContentType }}, {{ byteSize(<%= entityInstance %>.<%= fieldName %>) }}</span>
}
</td>
<%_ } else if (field.fieldIsEnum) { _%>
<%# TODO: import enum and use its key as label _%>
<td<% if (field.id) { %>><a<%- routerLink %><% } %> <%= jhiPrefix %>Translate="{{ '<%= frontendAppName %>.<%= fieldType %>.' + <%= entityInstance %>.<%= fieldName %> }}">{{ <%= entityInstance %>.<%= fieldName %> }}<% if (field.id) { %></a><% } %></td>
<td<% if (field.id) { %>><a<%- routerLink %><% } %>>__jhiTranslateTagEnum__('<%= frontendAppName %>.<%= fieldType %>', { "value": "<%= entityInstance %>.<%= fieldName %> ?? 'null'" })<% if (field.id) { %></a><% } %></td>
<%_ } else if (field.fieldTypeTimed) { _%>
<td>{{ <%= entityInstance %>.<%= fieldName %> | formatMediumDatetime }}</td>
<%_ } else if (field.fieldTypeLocalDate) { _%>
Expand Down Expand Up @@ -185,21 +185,21 @@ _%>
class="btn btn-info btn-sm"
data-cy="filterOtherEntityButton">
<fa-icon icon="eye"></fa-icon>
<span class="d-none d-md-inline" <%= jhiPrefix %>Translate="entity.action.show" [translateValues]="{ otherEntity: ('<%= otherEntityTranslationKey %>' | translate) }">__jhiTransformTranslate__('entity.action.show', { "otherEntity": "<%- relationship.otherEntity.entityClassHumanized %>" })</span>
<span class="d-none d-md-inline">__jhiTranslateTagPipe__('entity.action.show', { "otherEntity": "<%= otherEntityTranslationKey %>" })</span>
</button>
<%_ } _%>
<%_ } _%>
<a [routerLink]="['/<%= entityPage %>', <%= entityInstance %>.<%= primaryKey.name %>, 'view']"
class="btn btn-info btn-sm" data-cy="entityDetailsButton">
<fa-icon icon="eye"></fa-icon>
<span class="d-none d-md-inline" <%= jhiPrefix %>Translate="entity.action.view">__jhiTransformTranslate__('entity.action.view')</span>
<span class="d-none d-md-inline">__jhiTranslateTag__('entity.action.view')</span>
</a>
<%_ if (!readOnly && updatableEntity) { _%>

<a [routerLink]="['/<%= entityPage %>', <%= entityInstance %>.<%= primaryKey.name %>, 'edit']"
class="btn btn-primary btn-sm" data-cy="entityEditButton">
<fa-icon icon="pencil-alt"></fa-icon>
<span class="d-none d-md-inline" <%= jhiPrefix %>Translate="entity.action.edit">__jhiTransformTranslate__('entity.action.edit')</span>
<span class="d-none d-md-inline">__jhiTranslateTag__('entity.action.edit')</span>
</a>
<%_ } _%>
<%_ if (!readOnly) { _%>
Expand All @@ -208,7 +208,7 @@ _%>
class="btn btn-danger btn-sm"
data-cy="entityDeleteButton">
<fa-icon icon="times"></fa-icon>
<span class="d-none d-md-inline" <%= jhiPrefix %>Translate="entity.action.delete">__jhiTransformTranslate__('entity.action.delete')</span>
<span class="d-none d-md-inline">__jhiTranslateTag__('entity.action.delete')</span>
</button>
<%_ } _%>
</div>
Expand Down
Loading
Loading