Commit 31cf8a97 authored by Vitali Stupin's avatar Vitali Stupin
Browse files

Adding translations

parent 0c3c78da
......@@ -730,6 +730,22 @@
}
}
},
"@ngx-translate/core": {
"version": "11.0.1",
"resolved": "https://registry.npmjs.org/@ngx-translate/core/-/core-11.0.1.tgz",
"integrity": "sha512-nBCa1ZD9fAUY/3eskP3Lql2fNg8OMrYIej1/5GRsfcutx9tG/5fZLCv9m6UCw1aS+u4uK/vXjv1ctG/FdMvaWg==",
"requires": {
"tslib": "^1.9.0"
}
},
"@ngx-translate/http-loader": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@ngx-translate/http-loader/-/http-loader-4.0.0.tgz",
"integrity": "sha512-x8LumqydWD7eX9yQTAVeoCM9gFUIGVTUjZqbxdAUavAA3qVnk9wCQux7iHLPXpydl8vyQmLoPQR+fFU+DUDOMA==",
"requires": {
"tslib": "^1.9.0"
}
},
"@schematics/angular": {
"version": "7.3.3",
"resolved": "https://registry.npmjs.org/@schematics/angular/-/angular-7.3.3.tgz",
......
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {HttpClient, HttpClientModule} from '@angular/common/http';
import { AppComponent } from './app.component';
import { SubsystemListComponent } from './subsystem-list/subsystem-list.component';
......@@ -9,6 +11,7 @@ import { SearchComponent } from './subsystem-list/search/search.component';
import { SubsystemItemComponent } from './subsystem-list/subsystem-item/subsystem-item.component';
import { AppRoutingModule } from './app-routing.module';
import { SubsystemComponent } from './subsystem/subsystem.component';
import { HeaderComponent } from './header/header.component';
@NgModule({
declarations: [
......@@ -16,15 +19,27 @@ import { SubsystemComponent } from './subsystem/subsystem.component';
SubsystemListComponent,
SearchComponent,
SubsystemItemComponent,
SubsystemComponent
SubsystemComponent,
HeaderComponent
],
imports: [
BrowserModule,
HttpClientModule,
FormsModule,
AppRoutingModule
AppRoutingModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
})
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
}
\ No newline at end of file
<div class="row">
<div class="col">
<ul class="nav float-right">
<li *ngFor="let lang of getLangs()" class="nav-item">
<a [ngClass]="getLang() == lang ? 'nav-link font-weight-bold' : 'nav-link'"
onClick="return false" href="#" (click)="setLang(lang)">{{lang}}</a>
</li>
</ul>
</div>
</div>
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HeaderComponent } from './header.component';
describe('HeaderComponent', () => {
let component: HeaderComponent;
let fixture: ComponentFixture<HeaderComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HeaderComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HeaderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { LanguagesService } from '../languages.service';
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.css']
})
export class HeaderComponent implements OnInit {
constructor(private languagesService: LanguagesService) { }
ngOnInit() {
}
getLangs():string[] {
return this.languagesService.getLangs()
}
getLang():string {
return this.languagesService.getLang()
}
setLang(lang: string) {
return this.languagesService.setLang(lang)
}
}
import { TestBed } from '@angular/core/testing';
import { LanguagesService } from './languages.service';
describe('LanguagesService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: LanguagesService = TestBed.get(LanguagesService);
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import {TranslateService} from "@ngx-translate/core";
import { Title } from '@angular/platform-browser';
import { Subscription } from 'rxjs';
const LANGUAGES = {
'EST': 'est',
'ENG': 'eng'
}
@Injectable({
providedIn: 'root'
})
export class LanguagesService {
private selectedLang = ''
private translateSubscription: Subscription
constructor(
private translate: TranslateService,
private title: Title
) {
this.selectedLang = this.getDefaultLang()
translate.setDefaultLang(LANGUAGES[this.selectedLang])
this.updateTitle()
}
updateTitle(): void {
// Not subscribing if subscription already in progress
if (!this.translateSubscription || this.translateSubscription.closed) {
this.translateSubscription = this.translate.get('index.title').subscribe((res: string) => {
this.title.setTitle(res)
this.translateSubscription.unsubscribe()
});
}
}
getDefaultLang(): string {
if(window && window.localStorage && window.localStorage.getItem('lang')) {
return window.localStorage.getItem('lang')
}
return Object.keys(LANGUAGES)[0]
}
getLang(): string {
return this.selectedLang
}
getLangs(): string[] {
return Object.keys(LANGUAGES)
}
setLang(lang: string): void {
this.selectedLang = lang
if(window && window.localStorage) {
window.localStorage.setItem('lang', this.selectedLang)
}
this.translate.use(LANGUAGES[this.selectedLang]);
this.updateTitle()
}
}
......@@ -159,7 +159,7 @@ export class MethodsService {
getLimit(): string {
if (this.limit == MAX_LIMIT) {
return 'All'
return 'all'
}
return this.limit.toString()
}
......@@ -197,7 +197,7 @@ export class MethodsService {
case '50':
this.limit = 50;
break;
case 'All':
case 'all':
this.limit = MAX_LIMIT;
break;
default:
......
<div class="card">
<div class="card-header">
Search filters
{{'search.searchFilters' | translate}}
</div>
<div class="card-body">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="filterInput">Filter by method name</label>
<label for="filterInput">{{'search.nameFilter' | translate}}</label>
<input type="text" class="form-control" id="filterInput"
[(ngModel)]="filter" (ngModelChange)="setFilter(filter)">
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label for="limitSelect">Amount of subsystems to display</label>
<label for="limitSelect">{{'search.limit' | translate}}</label>
<select class="form-control" id="limitSelect"
[(ngModel)]="limit" (change)="setLimit(limit)">
<option>10</option>
<option>20</option>
<option>50</option>
<option>All</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="all">{{'search.allOption' | translate}}</option>
</select>
</div>
</div>
......@@ -27,7 +27,7 @@
<div class="form-check">
<input type="checkbox" class="form-check-input" id="nonEmptyCheck"
[(ngModel)]="nonEmpty" (change)="setNonEmpty(nonEmpty)">
<label class="form-check-label" for="nonEmptyCheck">Show only producer subsystems</label>
<label class="form-check-label" for="nonEmptyCheck">{{'search.nonEmpty' | translate}}</label>
</div>
</div>
</div>
......
<div class="card">
<div class="card-header pointerCursor" (click)="showDetail()">
{{subsystem.fullSubsystemName}}
<span class="badge badge-secondary" *ngIf="!subsystem.methods.length && subsystem.subsystemStatus == 'OK'">Empty</span>
<span class="badge badge-danger" *ngIf="subsystem.subsystemStatus == 'ERROR'">Error</span>
<span class="badge badge-secondary" *ngIf="!subsystem.methods.length && subsystem.subsystemStatus == 'OK'">{{'subsystem.statusEmpty' | translate}}</span>
<span class="badge badge-danger" *ngIf="subsystem.subsystemStatus == 'ERROR'">{{'subsystem.statusError' | translate}}</span>
</div>
<div class="card-body" *ngIf="subsystem.subsystemStatus == 'ERROR'">
<p>Subsystem either could not be reached by RIA's Monitoring Security Server
or there was some other error during the request.</p>
<p>{{'subsystem.statusErrorInfo' | translate}}</p>
</div>
<div class="card-body" *ngIf="subsystem.subsystemStatus == 'OK' && !subsystem.methods.length">
<p>Subsystem does not have any methods.</p>
<p>{{'subsystem.statusEmptyInfo' | translate}}</p>
</div>
<div class="card-body" *ngIf="subsystem.subsystemStatus == 'OK' && subsystem.methods.length">
<p *ngFor="let method of getMethodsPreview()">
{{method.fullMethodName}}
<a href="{{getApiUrlBase()}}{{method.wsdl}}" class="badge badge-success"
*ngIf="method.wsdl" [target]="'_blank'">WSDL</a>
<span class="badge badge-danger" *ngIf="!method.wsdl">Error while downloading or parsing of WSDL</span>
<span class="badge badge-danger" *ngIf="!method.wsdl">{{'subsystem.statusWsdlError' | translate}}</span>
</p>
<p *ngIf="getNotInPreview() > 0" class="pointerCursor" (click)="showDetail()">
{{getNotInPreview()}} more methods...
{{'subsystem.moreMethods' | translate:{"count": getNotInPreview()} }}
</p>
</div>
</div>
\ No newline at end of file
<h3>Catalogue of all X-tee subsystems with methods and WSDL descriptions</h3>
<p>This catalogue is generated by making getWsdl requests from RIA's Monitoring Security Server
to all X-tee subsystems.</p>
<p>Subsystems with the <span class="badge badge-secondary">Empty</span> icon have no X-Tee
services available.</p>
<p>Subsystems with the <span class="badge badge-danger">Error</span> icon either could not be
reached by RIA's Monitoring Security Server or there was some other error during the request.</p>
<p>Support: <a href="mailto:help@ria.ee">help@ria.ee</a></p>
<app-header></app-header>
<h3>{{'subsystemList.heading' | translate}}</h3>
<p [innerHTML]="'subsystemList.intro.p1' | translate"></p>
<p [innerHTML]="'subsystemList.intro.p2' | translate"></p>
<p [innerHTML]="'subsystemList.intro.p3' | translate"></p>
<p [innerHTML]="'subsystemList.intro.p4' | translate"></p>
<div class="alert alert-warning" role="alert" *ngIf="message">
{{message}}
</div>
<div class="btn-group" role="group" aria-label="Select X-tee instance">
<div class="btn-group" role="group" [attr.aria-label]="'subsystemList.selectInstance' | translate">
<button *ngFor="let instance of getInstances()"
type="button" [ngClass]="getInstance() == instance ? 'btn btn-primary' : 'btn btn-secondary'"
(click)="switchInstance(instance)">{{instance}}</button>
......
import { Component, OnInit } from '@angular/core';
import { Subsystem } from '../subsystem';
import { MethodsService } from '../methods.service';
import { LanguagesService } from '../languages.service';
import { ActivatedRoute, Router, Scroll } from '@angular/router';
import { Subscription } from 'rxjs';
import { ViewportScroller } from '@angular/common';
......@@ -22,6 +23,7 @@ export class SubsystemListComponent implements OnInit {
constructor(
private methodsService: MethodsService,
private languagesService: LanguagesService,
private route: ActivatedRoute,
private router: Router,
private viewportScroller: ViewportScroller
......
<h3>Subsystem {{subsystemId}} with methods and WSDL descriptions for
X-tee instance "{{getInstance()}}"</h3>
<p>Support: <a href="mailto:help@ria.ee">help@ria.ee</a></p>
<app-header></app-header>
<h3>{{'subsystem.heading' | translate:{"subsystem": subsystemId, "instance": getInstance()} }}</h3>
<p [innerHTML]="'subsystem.intro.p1' | translate"></p>
<div class="alert alert-warning" role="alert" *ngIf="message">
{{message}}
</div>
<button type="button" class="btn btn-secondary" (click)="goToList()">Show all subsystems</button>
<button type="button" class="btn btn-secondary" (click)="goToList()">{{'subsystem.allSystemsBtn' | translate}}</button>
<div *ngIf="subsystem">
<div class="card">
<div class="card-header">
{{subsystem.fullSubsystemName}}
<span class="badge badge-secondary" *ngIf="!subsystem.methods.length && subsystem.subsystemStatus == 'OK'">Empty</span>
<span class="badge badge-danger" *ngIf="subsystem.subsystemStatus == 'ERROR'">Error</span>
<span class="badge badge-secondary" *ngIf="!subsystem.methods.length && subsystem.subsystemStatus == 'OK'">{{'subsystem.statusEmpty' | translate}}</span>
<span class="badge badge-danger" *ngIf="subsystem.subsystemStatus == 'ERROR'">{{'subsystem.statusError' | translate}}</span>
</div>
<div class="card-body" *ngIf="subsystem.subsystemStatus == 'ERROR'">
<p>Subsystem either could not be reached by RIA's Monitoring Security Server
or there was some other error during the request.</p>
<p>{{'subsystem.statusErrorInfo' | translate}}</p>
</div>
<div class="card-body" *ngIf="subsystem.subsystemStatus == 'OK' && !subsystem.methods.length">
<p>Subsystem does not have any methods.</p>
<p>{{'subsystem.statusEmptyInfo' | translate}}</p>
</div>
<div class="card-body" *ngIf="subsystem.subsystemStatus == 'OK' && subsystem.methods.length">
<p *ngFor="let method of subsystem.methods">
{{method.fullMethodName}}
<a href="{{getApiUrlBase()}}{{method.wsdl}}" class="badge badge-success"
*ngIf="method.wsdl" [target]="'_blank'">WSDL</a>
<span class="badge badge-danger" *ngIf="!method.wsdl">Error while downloading or parsing of WSDL</span>
<span class="badge badge-danger" *ngIf="!method.wsdl">{{'subsystem.statusWsdlError' | translate}}</span>
</p>
</div>
</div>
......
{
"index": {
"title": "X-tee Subsystems and Methods catalogue"
},
"subsystemList": {
"heading": "Catalogue of all X-tee subsystems with methods and WSDL descriptions",
"intro": {
"p1": "This catalogue is generated by making getWsdl requests from RIA's Monitoring Security Server to all X-tee subsystems.",
"p2": "Subsystems with the <span class=\"badge badge-secondary\">Empty</span> icon have no X-Tee services available.",
"p3": "Subsystems with the <span class=\"badge badge-danger\">Error</span> icon either could not be reached by RIA's Monitoring Security Server or there was some other error during the request.",
"p4": "Support: <a href=\"mailto:help@ria.ee\">help@ria.ee</a>"
},
"selectInstance": "Select X-tee instance"
},
"search": {
"searchFilters": "Search filters",
"nameFilter": "Filter by name",
"limit": "Amount of subsystems to display",
"nonEmpty": "Show only producer subsystems",
"allOption": "All"
},
"subsystem": {
"heading": "Subsystem {{subsystem}} with methods and WSDL descriptions for X-tee instance \"{{instance}}\"",
"intro": {
"p1": "Kasutajatugi: <a href=\"mailto:help@ria.ee\">help@ria.ee</a>"
},
"statusEmpty": "Empty",
"statusError": "Error",
"statusWsdlError": "Error while downloading or parsing of WSDL",
"allSystemsBtn": "Show all subsystems",
"statusErrorInfo": "Subsystem either could not be reached by RIA's Monitoring Security Server or there was some other error during the request.",
"statusEmptyInfo": "Subsystem does not have any methods.",
"moreMethods": "{{count}} more methods..."
}
}
\ No newline at end of file
{
"index": {
"title": "X-tee alamsüsteemide ja teenuste kataloog"
},
"subsystemList": {
"heading": "X-tee alamsüsteemide kataloog teenuste ja WSDL kirjeldustega",
"intro": {
"p1": "Antud kataloog on genereeritud saates getWsdl päringud RIA monitooringu turvaserverist kõigi X-tee alamsüsteemide pihta.",
"p2": "Alamsüsteemid <span class=\"badge badge-secondary\">Tühi</span> ikooniga ei oma X-Tee teenuseid.",
"p3": "Alamsüsteemid <span class=\"badge badge-danger\">Viga</span> ikooniga kas ei ole liigipääsetavad RIA monitooringu turvaserveri poolt, või päringu tegemisel ilmnes muu viga.",
"p4": "Kasutajatugi: <a href=\"mailto:help@ria.ee\">help@ria.ee</a>"
},
"selectInstance": "Vali X-tee instants"
},
"search": {
"searchFilters": "Otsingu filtrid",
"nameFilter": "Filtreeri nime järgi",
"limit": "Alamsüsteemide näitamise piirang",
"nonEmpty": "Näita vaid teenustepakkujad",
"allOption": "Kõik"
},
"subsystem": {
"heading": "Alamsüsteem {{subsystem}} teenuste ja WSDL kirjeldustega X-tee instantsi \"{{instance}}\" jaoks",
"intro": {
"p1": "Kasutajatugi: <a href=\"mailto:help@ria.ee\">help@ria.ee</a>"
},
"statusEmpty": "Tühi",
"statusError": "Viga",
"statusWsdlError": "Viga WSDL'i laadimisel või töötlemisel",
"allSystemsBtn": "Näita kõik alamsüsteemid",
"statusErrorInfo": "Alamsüsteem kas ei ole liigipääsetav RIA monitooringu turvaserveri poolt, või päringu tegemisel ilmnes muu viga.",
"statusEmptyInfo": "Alamsüsteem ei oma X-Tee teenuseid.",
"moreMethods": "veel {{count}} teenust..."
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment