Skip to content

Commit

Permalink
SHIBUI-814 Fixes in templates for translations
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Sep 20, 2018
1 parent 8ec0332 commit 7885824
Show file tree
Hide file tree
Showing 24 changed files with 67 additions and 36 deletions.
3 changes: 2 additions & 1 deletion backend/src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
action.dashboard=Dashboard
action.logout=Logout
action.add=Add
action.add-new=Add New
action.add-new-provider=Add a new metadata provider
action.add-new-source=Add a new metadata source
Expand Down Expand Up @@ -231,7 +232,7 @@ label.script=Script
label.metadata-filter=Metadata Filter
label.metadata-filter-type=Metadata Filter Type

label.http-connnection-attributes=HTTP Connection Attributes
label.http-connection-attributes=HTTP Connection Attributes
label.http-security-attributes=HTTP Security Attributes
label.http-proxy-attributes=HTTP Proxy Attributes
label.http-caching-attributes=HTTP Caching Attributes
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
{{ formatted$ | async }}
 | 
</ng-container>
<translate-i18n key="label.copyright" [params]="{ year: year }">Copyright &copy; Internet2</translate-i18n>
<translate-i18n key="brand.footer.copyright" [params]="{ year: year }">Copyright &copy; Internet2</translate-i18n>
</p>
</div>
<div class="col-md-4 logo">
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/i18n/component/translate.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class TranslateComponent implements OnDestroy {

@Input() set params(params: any) {
this.currentParams = params || {};
console.log(params);
this.update();
}

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/i18n/directive/translate.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class TranslateDirective implements OnDestroy {
update(): void {
const translated = this.service.translate(this.key, this.currentParams, this.messages);
this.element.nativeElement.textContent = translated;
// this.element.nativeElement.data = translated;
this.element.nativeElement.data = translated;
}

ngOnDestroy() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="row">
<div class="col-xl-6 col-xs-12" *ngFor="let sections of columns">
<section class="px-3" *ngFor="let section of sections; let i = index;" role="list">
<button (click)="gotoPage(section.id)" class="tag tag-success tag-sm my-4 text-left" [attr.aria-label]="section.label" role="button">
<button (click)="gotoPage(section.id)" class="tag tag-success tag-sm my-4 text-left" [attr.aria-label]="section.label | translate" role="button">
<span class="index">{{ section.index }}</span>
<ng-container>{{ section.label }}</ng-container>
<translate-i18n [key]="section.label">{{ section.label }}</translate-i18n>
</button>
<ng-container *ngFor="let prop of section.properties">
<summary-property [property]="prop" role="listitem"></summary-property>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<ng-container [ngSwitch]="property.type">
<ng-container *ngSwitchDefault>
<ng-container *ngIf="property.name">
<strong class="text-primary d-block" role="term">{{ property.name }}</strong>
<strong class="text-primary d-block" role="term" [translate]="property.name">{{ property.name }}</strong>
<span class="d-block" role="definition">{{ property.value || property.value === false ? property.value : '-' }}</span>
</ng-container>
</ng-container>
<ng-container *ngSwitchCase="'object'">
<ng-container *ngIf="property.name">
<span class="text-primary d-block" role="term">{{ property.name }}</span>
<span class="text-primary d-block" role="term" [translate]="property.name">{{ property.name }}</span>
</ng-container>
<ng-container *ngIf="property.properties">
<summary-property *ngFor="let prop of property.properties" [property]="prop"></summary-property>
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/schema-form/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CustomIntegerComponent } from './widget/number/number.component';
import { FilterTargetComponent } from './widget/filter-target/filter-target.component';
import { ChecklistComponent } from './widget/check/checklist.component';
import { IconButtonComponent } from './widget/button/icon-button.component';

import { CustomObjectWidget } from './widget/object/object.component';

export class CustomWidgetRegistry extends WidgetRegistry {
constructor() {
Expand All @@ -38,7 +38,7 @@ export class CustomWidgetRegistry extends WidgetRegistry {
this.register('boolean-radio', BooleanRadioComponent);

this.register('fieldset', FieldsetComponent);
this.register('object', ObjectWidget);
this.register('object', CustomObjectWidget);

this.register('array', CustomArrayComponent);
this.register('checklist', ChecklistComponent);
Expand Down
4 changes: 3 additions & 1 deletion ui/src/app/schema-form/schema-form.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { FilterTargetComponent } from './widget/filter-target/filter-target.comp
import { ChecklistComponent } from './widget/check/checklist.component';
import { IconButtonComponent } from './widget/button/icon-button.component';
import { I18nModule } from '../i18n/i18n.module';
import { CustomObjectWidget } from './widget/object/object.component';

export const COMPONENTS = [
BooleanRadioComponent,
Expand All @@ -32,7 +33,8 @@ export const COMPONENTS = [
CustomIntegerComponent,
FilterTargetComponent,
ChecklistComponent,
IconButtonComponent
IconButtonComponent,
CustomObjectWidget
];

@NgModule({
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/schema-form/widget/array/array.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="widget form-group">
<div class="d-flex justify-content-start">
<label [attr.for]="id" class="m-0 pt-1 control-label">
{{ schema.title }}
<translate-i18n [key]="schema.title">{{ schema.title }}</translate-i18n>
</label>
&nbsp;
<button (click)="addItem()" class="btn btn-success btn-sm array-add-button">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<label class="d-flex justify-content-start control-label">
<span [translate]="schema.title">{{ schema.title }}</span>
<span *ngIf="schema.description">
<ng-template #tooltip translate="tooltip.description">
<ng-template #tooltip>
<translate-i18n [key]="schema.description">{{ schema.description }}</translate-i18n>
</ng-template>
<i class="info-icon fa fa-fw fa-info-circle text-primary fa-lg"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<fieldset [attr.aria-label]="schema.description" tabindex="0">
<legend *ngIf="schema.title">{{ schema.title }}</legend>
<legend *ngIf="schema.title" [translate]="schema.title">{{ schema.title }}</legend>
<table class="table table-striped table-sm">
<thead>
<tr class="table-secondary">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div class="widget form-group">
<label [for]="id" class="d-flex justify-content-between control-label">
<span [ngClass]="{'sr-only': formProperty.parent.schema.type === 'array'}">
{{ schema.title }}
<translate-i18n [key]="schema.title">{{ schema.title }}</translate-i18n>
<i class="fa fa-asterisk text-danger" aria-hidden="true" *ngIf="required"></i>
</span>
<span *ngIf="schema.description">
<ng-template #tooltip>
<translate-i18n key="tooltip.description">{{ schema.description }}</translate-i18n>
<translate-i18n [key]="schema.description">{{ schema.description }}</translate-i18n>
</ng-template>
<i class="info-icon fa fa-fw fa-info-circle text-primary fa-lg"
[ngbPopover]="tooltip"
Expand All @@ -22,9 +22,9 @@
[matches]="schema.widget.data"
[required]="true"
[dropdown]="true"
[placeholder]="schema.placeholder || ''"
[attr.placeholder]="schema.placeholder || '' | translate"
[attr.disabled]="schema.readOnly?true:null"
role="textbox"
[attr.aria-label]="schema.title">
[attr.aria-label]="schema.title | translate">
</auto-complete>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
[class.d-none]="fieldset.type === 'hidden'"
[class.col-lg-6]="fieldset.type === 'group'"
[class.col-lg-12]="fieldset.type === 'group-lg'">
<legend class="text-primary" *ngIf="fieldset.title" [translate]="fieldset.title">{{ fieldset.title }}</legend>
<legend class="text-primary" *ngIf="fieldset.title">
<translate-i18n [key]="fieldset.title">{{ fieldset.title }}</translate-i18n>
</legend>
<p *ngIf="fieldset.description" [translate]="fieldset.description">{{ fieldset.description }}</p>
<div [ngClass]="{
'bg-light border rounded px-4 pt-4 pb-1': fieldset.type === 'section' || (!fieldset.type && formProperty.schema.widget.id === 'fieldset')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
<span>
<translate-i18n key="action.search-by">Search By</translate-i18n> <i class="fa fa-asterisk text-danger" aria-hidden="true"></i></span>
<span>
<ng-template #tooltipBy translate="tooltip.description">
<ng-template #tooltipBy>
<translate-i18n key="action.search-by">Search By</translate-i18n>
</ng-template>
<i class="info-icon fa fa-fw fa-info-circle text-primary fa-lg"
[ngbPopover]="tooltipBy"

[attr.aria-label]="'tooltip.instruction' | translate"></i>
</span>
</label>
Expand Down Expand Up @@ -40,14 +39,16 @@
<div>
<label for="targetInput" class="d-flex justify-content-start control-label">
<span>
<translate-i18n key="label.search-criteria-by" params="{ displayType }">Search Criteria by {{ this.displayType }}</translate-i18n>
<translate-i18n key="label.search-criteria-by" [params]="{ displayType: (displayType | translate) }">
Search Criteria by {{ this.displayType | translate }}
</translate-i18n>
<i class="fa fa-asterisk text-danger"
aria-hidden="true"
*ngIf="entityAttributesFilterTargetType !== 'ENTITY'"></i>
</span>
<span>
<ng-template #tooltipCriteria>
<translate-i18n key="label.search-criteria-by" params="{ displayType }">Search Criteria by {{ this.displayType }}</translate-i18n>
<translate-i18n key="label.search-criteria-by" [params]="{ displayType: (displayType | translate) }">Search Criteria by {{ this.displayType }}</translate-i18n>
</ng-template>
<i class="info-icon fa fa-fw fa-info-circle text-primary fa-lg"
[ngbPopover]="tooltipCriteria"
Expand Down
9 changes: 6 additions & 3 deletions ui/src/app/schema-form/widget/number/number.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<div class="widget form-group">
<label [attr.for]="id" class="d-flex justify-content-between control-label">
<span>{{ schema.title }} <i class="fa fa-asterisk text-danger" aria-hidden="true" *ngIf="required"></i></span>
<span>
<translate-i18n [key]="schema.title">{{ schema.title }}</translate-i18n>
<i class="fa fa-asterisk text-danger" aria-hidden="true" *ngIf="required"></i>
</span>
<span *ngIf="schema.description">
<ng-template #tooltip translate="tooltip.description">
<ng-template #tooltip>
<translate-i18n [key]="schema.description">{{ schema.description }}</translate-i18n>
</ng-template>
<i class="info-icon fa fa-fw fa-info-circle text-primary fa-lg"
Expand All @@ -19,7 +22,7 @@
[attr.type]="'number'"
[attr.min]="schema.minimum"
[attr.max]="schema.maximum"
[attr.placeholder]="schema.placeholder"
[attr.placeholder]="schema.placeholder | translate"
[attr.maxLength]="schema.maxLength || null"
[attr.minLength]="schema.minLength || null"
[attr.step]="schema.multipleOf || schema.widget.step"
Expand Down
7 changes: 7 additions & 0 deletions ui/src/app/schema-form/widget/object/object.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<fieldset *ngFor="let fieldset of formProperty.schema.fieldsets">
<legend *ngIf="fieldset.title" [translate]="fieldset.title">{{fieldset.title}}</legend>
<div *ngIf="fieldset.description" [translate]="fieldset.description">{{fieldset.description}}</div>
<div *ngFor="let fieldId of fieldset.fields">
<sf-form-element [formProperty]="formProperty.getProperty(fieldId)"></sf-form-element>
</div>
</fieldset>
10 changes: 10 additions & 0 deletions ui/src/app/schema-form/widget/object/object.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

import { ObjectWidget } from 'ngx-schema-form';

/* tslint:disable */
@Component({
selector: 'custom-object',
templateUrl: `./object.component.html`
})
export class CustomObjectWidget extends ObjectWidget { }
6 changes: 3 additions & 3 deletions ui/src/app/schema-form/widget/select/select.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<i class="fa fa-asterisk text-danger" aria-hidden="true" *ngIf="required"></i>
</span>
<span *ngIf="schema.description">
<ng-template #tooltip translate="tooltip.description">
<ng-template #tooltip>
<translate-i18n [key]="schema.description">{{ schema.description }}</translate-i18n>
</ng-template>
<i class="info-icon fa fa-fw fa-info-circle text-primary fa-lg"
Expand All @@ -23,8 +23,8 @@
class="form-control"
[attr.aria-label]="schema.title">
<option disabled selected>
<translate-i18n *ngIf="schema.placeholder">{{ schema.placeholder }}</translate-i18n>
<translate-i18n *ngIf="!schema.placeholder">{{ schema.title }}</translate-i18n>
<translate-i18n *ngIf="schema.placeholder" [key]="schema.placeholder">{{ schema.placeholder }}</translate-i18n>
<translate-i18n *ngIf="!schema.placeholder" [key]="schema.title">{{ schema.title }}</translate-i18n>
</option>
<option *ngFor="let option of schema.oneOf" [ngValue]="option.enum[0]" [translate]="option.description">{{ option.description }}</option>
</select>
Expand Down
8 changes: 5 additions & 3 deletions ui/src/app/schema-form/widget/string/string.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<span>
<translate-i18n [key]="schema.title">{{ schema.title }}</translate-i18n> <i class="fa fa-asterisk text-danger" aria-hidden="true" *ngIf="required"></i></span>
<span *ngIf="schema.description">
<ng-template #tooltip translate="tooltip.description">
<ng-template #tooltip>
<translate-i18n [key]="schema.description">{{ schema.description }}</translate-i18n>
</ng-template>
<i class="info-icon fa fa-fw fa-info-circle text-primary fa-lg"
Expand All @@ -19,7 +19,7 @@
[attr.type]="this.getInputType()"
[attr.id]="id"
[formControl]="control"
[attr.placeholder]="schema.placeholder"
[attr.placeholder]="schema.placeholder | translate"
[attr.maxLength]="schema.maxLength || null"
[attr.minLength]="schema.minLength || null"
[attr.disabled]="(schema.widget.id=='color' && schema.readOnly)?true:null"
Expand All @@ -28,7 +28,9 @@
<small class="form-text text-danger" *ngIf="errorMessages && errorMessages.length && control.touched">
{{ errorMessages }}
</small>
<small class="form-text text-secondary" *ngIf="!(control.touched && errorMessages && errorMessages.length) && schema.widget.help" [translate]="schema.widget.help">
<small class="form-text text-secondary"
*ngIf="!(control.touched && errorMessages && errorMessages.length) && schema.widget.help"
[translate]="schema.widget.help">
{{ schema.widget.help }}
</small>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<i class="fa fa-asterisk text-danger" aria-hidden="true" *ngIf="required"></i>
</span>
<span *ngIf="schema.description">
<ng-template #tooltip translate="tooltip.description">
<ng-template #tooltip>
<translate-i18n [key]="schema.description">{{ schema.description }}</translate-i18n>
</ng-template>
<i class="info-icon fa fa-fw fa-info-circle text-primary fa-lg"
Expand Down
4 changes: 3 additions & 1 deletion ui/src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import { PrettyXml } from './pipe/pretty-xml.pipe';
import { ToggleSwitchComponent } from './switch/switch.component';
import { ContenteditableDirective } from './contenteditable/contenteditable.directive';
import { ReplacePipe } from './pipe/replace.pipe';
import { I18nModule } from '../i18n/i18n.module';

@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule
ReactiveFormsModule,
I18nModule
],
declarations: [
HighlightPipe,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/assets/schema/filter/metadata-filter.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "string",
"widget": {
"id": "string",
"help": "message.unique"
"help": "message.must-be-unique"
}
},
"@type": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"type": "string",
"widget": {
"id": "string",
"help": "message.unique"
"help": "message.must-be-unique"
}
},
"@type": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "string",
"widget": {
"id": "string",
"help": "message.unique"
"help": "message.must-be-unique"
}
},
"@type": {
Expand Down

0 comments on commit 7885824

Please sign in to comment.