gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[reclaim-ui] 327/459: new localesService


From: gnunet
Subject: [reclaim-ui] 327/459: new localesService
Date: Fri, 11 Jun 2021 23:26:59 +0200

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository reclaim-ui.

commit 047af24d45fe93f63b678fc4cfcfbc2f1fc985a5
Author: anna wimbauer <anna.wibauer@gmx.de>
AuthorDate: Wed Oct 7 12:36:13 2020 +0200

    new localesService
---
 src/app/app.component.ts                           | 15 ++++-------
 .../authorization-request.component.ts             | 13 +++-------
 .../edit-authorizations.component.ts               | 14 +++-------
 .../edit-credentials.component.html                |  2 +-
 .../edit-credentials/edit-credentials.component.ts | 14 +++-------
 src/app/edit-identity/edit-identity.component.html | 30 +++++++++++-----------
 src/app/edit-identity/edit-identity.component.ts   | 12 +++------
 src/app/identity-list/identity-list.component.html |  2 +-
 src/app/identity-list/identity-list.component.ts   | 11 +++-----
 src/app/locales.service.spec.ts                    | 16 ++++++++++++
 src/app/locales.service.ts                         | 26 +++++++++++++++++++
 src/app/new-identity/new-identity.component.ts     | 12 +++------
 12 files changed, 84 insertions(+), 83 deletions(-)

diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 79a3ba3..8cdb324 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -1,7 +1,6 @@
 import { Component } from '@angular/core';
 import { ConfigService } from './config.service';
-
-declare var chrome: any;
+import { LocalesService } from './locales.service';
 
 @Component({
   selector: 'app-root',
@@ -12,7 +11,9 @@ export class AppComponent {
   title = 'app';
   configService: any;
 
-  constructor(private _configService: ConfigService) {
+  constructor(private _configService: ConfigService,
+              private localesService: LocalesService) 
+              {
     this.configService = _configService;
   }
 
@@ -26,13 +27,7 @@ export class AppComponent {
 
   //Internationalization
   getMessage(key, sub?){
-    var usrAgent = navigator.userAgent;
-    if (usrAgent.indexOf("Firefox") > -1){
-      return browser.i18n.getMessage(key, sub);
-    }
-    else if (usrAgent.indexOf("Chrome") > -1){
-      return chrome.i18n.getMessage(key, sub);
-    }
+    return this.localesService.getMessage(key, sub);
   }
 
 }
diff --git a/src/app/authorization-request/authorization-request.component.ts 
b/src/app/authorization-request/authorization-request.component.ts
index d327761..91c6bbf 100644
--- a/src/app/authorization-request/authorization-request.component.ts
+++ b/src/app/authorization-request/authorization-request.component.ts
@@ -1,9 +1,7 @@
 import { Component, OnInit } from '@angular/core';
 import { Router } from '@angular/router';
 import { OpenIdService } from '../open-id.service';
-
-/* For Chrome browsers */
-declare var chrome: any;
+import { LocalesService } from '../locales.service';
 
 @Component({
   selector: 'app-authorization-request',
@@ -15,6 +13,7 @@ export class AuthorizationRequestComponent implements OnInit {
   browser: typeof browser;
 
   constructor(private oidcService: OpenIdService,
+              private localesService: LocalesService,
               private router: Router) { }
 
   ngOnInit() {
@@ -47,13 +46,7 @@ export class AuthorizationRequestComponent implements OnInit 
{
 
   //Internationalization
   getMessage(key, sub?){
-    var usrAgent = navigator.userAgent;
-    if (usrAgent.indexOf("Firefox") > -1){
-      return browser.i18n.getMessage(key, sub);
-    }
-    else if (usrAgent.indexOf("Chrome") > -1) {
-      return (chrome as any).i18n.getMessage(key, sub);
-    }
+    return this.localesService.getMessage(key, sub);
   }
 
 
diff --git a/src/app/edit-authorizations/edit-authorizations.component.ts 
b/src/app/edit-authorizations/edit-authorizations.component.ts
index 08c85f5..6d9a076 100644
--- a/src/app/edit-authorizations/edit-authorizations.component.ts
+++ b/src/app/edit-authorizations/edit-authorizations.component.ts
@@ -7,8 +7,7 @@ import { ActivatedRoute } from '@angular/router';
 import { IdentityService } from '../identity.service';
 import { GnsService } from '../gns.service';
 import { NamestoreService } from '../namestore.service';
-
-declare var chrome: any;
+import { LocalesService } from '../locales.service';
 
 @Component({
   selector: 'app-edit-authorizations',
@@ -28,7 +27,8 @@ export class EditAuthorizationsComponent implements OnInit {
               private activatedRoute: ActivatedRoute,
               private identityService: IdentityService,
               private gnsService: GnsService,
-              private namestoreService: NamestoreService) { }
+              private namestoreService: NamestoreService,
+              private localesService: LocalesService,) { }
 
   ngOnInit() {
     this.tickets = [];
@@ -144,13 +144,7 @@ export class EditAuthorizationsComponent implements OnInit 
{
 
   //Internationalization
   getMessage(key, sub?){
-    var usrAgent = navigator.userAgent;
-    if (usrAgent.indexOf("Firefox") > -1){
-      return browser.i18n.getMessage(key, sub);
-    }
-    else if (usrAgent.indexOf("Chrome") > -1){
-      return chrome.i18n.getMessage(key, sub);
-    }
+    return this.localesService.getMessage(key, sub);
   }
 
 
diff --git a/src/app/edit-credentials/edit-credentials.component.html 
b/src/app/edit-credentials/edit-credentials.component.html
index cd40e61..dc2bea2 100644
--- a/src/app/edit-credentials/edit-credentials.component.html
+++ b/src/app/edit-credentials/edit-credentials.component.html
@@ -105,7 +105,7 @@
         </tr>
         <tr [class.alert-danger]="isCredInConflict(newCredential)" 
*ngIf="loggedIn()">
           <td>
-            <input [class.text-danger]="!credentialNameValid(newCredential)" 
placeholder="Credential"
+            <input [class.text-danger]="!credentialNameValid(newCredential)" 
placeholder="{{getMessage('edit_credentials_html@credentials')}}"
               [(ngModel)]="newCredential.name">
           </td>
           <td>
diff --git a/src/app/edit-credentials/edit-credentials.component.ts 
b/src/app/edit-credentials/edit-credentials.component.ts
index 06bc1c1..1c347fb 100644
--- a/src/app/edit-credentials/edit-credentials.component.ts
+++ b/src/app/edit-credentials/edit-credentials.component.ts
@@ -11,8 +11,7 @@ import { OAuthService } from 'angular-oauth2-oidc';
 import { IdProvider } from '../idProvider';
 import { LoginOptions } from 'angular-oauth2-oidc';
 import { Scope } from '../scope';
-
-declare var chrome: any;
+import { LocalesService } from '../locales.service';
 
 @Component({
   selector: 'app-edit-credentials',
@@ -35,7 +34,8 @@ export class EditCredentialsComponent implements OnInit {
               private activatedRoute: ActivatedRoute,
               private router: Router,
               private credentialService: CredentialService,
-              private oauthService: OAuthService) { }
+              private oauthService: OAuthService,
+              private localesService: LocalesService,) { }
 
   ngOnInit() {
     this.newCredential = new Credential('', '', '', 'JWT', '', 0, []);
@@ -359,13 +359,7 @@ export class EditCredentialsComponent implements OnInit {
 
   //Internationalization
   getMessage(key, sub?){
-    var usrAgent = navigator.userAgent;
-    if (usrAgent.indexOf("Firefox") > -1){
-      return browser.i18n.getMessage(key, sub);
-    }
-    else if (usrAgent.indexOf("Chrome") > -1){
-      return chrome.i18n.getMessage(key, sub);
-    }
+    return this.localesService.getMessage(key, sub);
   }
 
 
diff --git a/src/app/edit-identity/edit-identity.component.html 
b/src/app/edit-identity/edit-identity.component.html
index 2e21c24..95bdf01 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -28,7 +28,7 @@
               </div>
             </div>
             <div class="col-sm">
-              <input *ngIf="!isClaimCred(claim)" placeholder="Value" 
[(ngModel)]="claim.value">
+              <input *ngIf="!isClaimCred(claim)" placeholder="{{ 
getMessage('Value') }}" [(ngModel)]="claim.value">
               <span *ngIf="isClaimCred(claim)"  
>{{getMessage("edit_identity_html@claimAsAttribute", [getCredValue(claim), 
getIssuer(claim), claim.value])}}</span>
             </div>
             <div class="col-sm">
@@ -49,8 +49,8 @@
                 <i *ngIf="isClaimRequested(claim)" class="fa 
fa-openid"></i><b> {{ getDescription(claim) }}</b></div></div>
             <div class="col-sm">
               <!-- FIXME Allow adding of credential OR plain value -->
-              <input placeholder="Value" [(ngModel)]="claim.value">
-              <!--<input *ngIf="!isClaimCred(claim)" placeholder="Value" 
[(ngModel)]="claim.value">
+              <input placeholder="{{ getMessage('Value') }}" 
[(ngModel)]="claim.value">
+              <!--<input *ngIf="!isClaimCred(claim)" placeholder="{{ 
getMessage('Value') }}" [(ngModel)]="claim.value">
               <span *ngIf="isClaimCred(claim)" >{{ getCredValue(claim) }} 
issued by <i>{{ getIssuer(claim) }}</i> as attribute for ``{{ claim.value 
}}''</span>-->
             </div>
             <div class="col-sm">
@@ -69,7 +69,7 @@
             <div class="col-sm"><div style="min-width: 15em">
                 <i *ngIf="isClaimRequested(claim)" class="fa 
fa-openid"></i><b> {{ getDescription(claim) }}</b></div></div>
             <div class="col-sm">
-              <input *ngIf="!isClaimCred(claim)" placeholder="Value" 
[(ngModel)]="claim.value">
+              <input *ngIf="!isClaimCred(claim)" placeholder="{{ 
getMessage('Value') }}" [(ngModel)]="claim.value">
               <span *ngIf="isClaimCred(claim)" 
>{{getMessage("edit_identity_html@claimAsAttribute", [getCredValue(claim), 
getIssuer(claim), claim.value])}}</span>
             </div>
             <div class="col-sm">
@@ -90,8 +90,8 @@
                 <i *ngIf="isClaimRequested(claim)" class="fa 
fa-openid"></i><b> {{ getDescription(claim) }}</b></div></div>
             <div class="col-sm">
               <!-- FIXME Allow adding of credential OR plain value -->
-              <input placeholder="Value" [(ngModel)]="claim.value">
-              <!--<input *ngIf="!isClaimCred(claim)" placeholder="Value" 
[(ngModel)]="claim.value">
+              <input placeholder="{{ getMessage('Value') }}" 
[(ngModel)]="claim.value">
+              <!--<input *ngIf="!isClaimCred(claim)" placeholder="{{ 
getMessage('Value') }}" [(ngModel)]="claim.value">
               <span *ngIf="isClaimCred(claim)" >{{ getCredValue(claim) }} 
issued by <i>{{ getIssuer(claim) }}</i> as attribute for ``{{ claim.value 
}}''</span>-->
             </div>
             <div class="col-sm">
@@ -112,7 +112,7 @@
             <div class="col-sm"><div style="min-width: 15em">
                 <i *ngIf="isClaimRequested(claim)" class="fa 
fa-openid"></i><b> {{ getDescription(claim) }}</b></div></div>
             <div class="col-sm">
-              <input *ngIf="!isClaimCred(claim)" placeholder="Value" 
[(ngModel)]="claim.value">
+              <input *ngIf="!isClaimCred(claim)" placeholder="{{ 
getMessage('Value') }}" [(ngModel)]="claim.value">
               <span *ngIf="isClaimCred(claim)" 
>{{getMessage("edit_identity_html@claimAsAttribute", [getCredValue(claim), 
getIssuer(claim), claim.value])}}</span>
             </div>
             <div class="col-sm">
@@ -133,8 +133,8 @@
                 <i *ngIf="isClaimRequested(claim)" class="fa 
fa-openid"></i><b> {{ getDescription(claim) }}</b></div></div>
             <div class="col-sm">
               <!-- FIXME Allow adding of credential OR plain value -->
-              <input placeholder="Value" [(ngModel)]="claim.value">
-              <!--<input *ngIf="!isClaimCred(claim)" placeholder="Value" 
[(ngModel)]="claim.value">
+              <input placeholder="{{ getMessage('Value') }}" 
[(ngModel)]="claim.value">
+              <!--<input *ngIf="!isClaimCred(claim)" placeholder="{{ 
getMessage('Value') }}" [(ngModel)]="claim.value">
               <span *ngIf="isClaimCred(claim)" >{{ getCredValue(claim) }} 
issued by <i>{{ getIssuer(claim) }}</i> as attribute for ``{{ claim.value 
}}''</span>-->
             </div>
             <div class="col-sm">
@@ -154,7 +154,7 @@
             <div class="col-sm"><div style="min-width: 15em">
                 <i *ngIf="isClaimRequested(claim)" class="fa 
fa-openid"></i><b> {{ getDescription(claim) }}</b></div></div>
             <div class="col-sm">
-              <input *ngIf="!isClaimCred(claim)" placeholder="Value" 
[(ngModel)]="claim.value">
+              <input *ngIf="!isClaimCred(claim)" placeholder="{{ 
getMessage('Value') }}" [(ngModel)]="claim.value">
               <span *ngIf="isClaimCred(claim)" 
>{{getMessage("edit_identity_html@claimAsAttribute", [getCredValue(claim), 
getIssuer(claim), claim.value])}}</span>
             </div>
             <div class="col-sm">
@@ -179,7 +179,7 @@
                 <option value="1">{{ 
getMessage("edit_identity_html@credential") }}</option>
               </select>
 
-              <input *ngIf="claim.flag == '0'" placeholder="Value" 
[(ngModel)]="claim.value">
+              <input *ngIf="claim.flag == '0'" placeholder="{{ 
getMessage('Value') }}" [(ngModel)]="claim.value">
               <select *ngIf="claim.flag == '1'" class="custom-select"
                 (change)="claim.credential=$event.target.value; " >
                 <option value="">{{ 
getMessage("edit_identity_html@selectSource") }}</option>
@@ -220,7 +220,7 @@
             <div class="col-sm"><div style="min-width: 15em">
                 <i *ngIf="isClaimRequested(missing)" class="fa 
fa-openid"></i><b> {{missing.name}}</b></div></div>
             <div class="col-sm">
-              <input *ngIf="!isClaimCredentialRequested(missing)" 
placeholder="Value" [(ngModel)]="missing.value">
+              <input *ngIf="!isClaimCredentialRequested(missing)" 
placeholder="{{ getMessage('Value') }}" [(ngModel)]="missing.value">
               <select *ngIf="isClaimCredentialRequested(missing)" 
class="custom-select" (change)="missing.credential=$event.target.value; ">
                 <option value="">{{ 
getMessage("edit_identity_html@selectSource") }}</option>
                 <option *ngFor="let cred of credentials" value={{cred.id}}>
@@ -251,7 +251,7 @@
               <i *ngIf="isClaimRequested(attribute)" class="fa 
fa-openid"></i><b> {{ attribute.name }}</b>
             </div>
             <div class="col-sm">
-              <input *ngIf="!isClaimCred(attribute)" placeholder="Value" 
[(ngModel)]="attribute.value">
+              <input *ngIf="!isClaimCred(attribute)" placeholder="{{ 
getMessage('Value') }}" [(ngModel)]="attribute.value">
               <span *ngIf="isClaimCred(attribute)" 
>{{getMessage("edit_identity_html@claimAsAttribute", [getCredValue(claim), 
getIssuer(claim), claim.value])}}</span>
             </div>
             <div class="col-sm">
@@ -266,7 +266,7 @@
           <!-- New Attribute -->
           <div class="row mb-3" 
[class.alert-danger]="isInConflict(newAttribute)">
             <div class="col-sm">
-              <input [class.text-danger]="!attributeNameValid(newAttribute)" 
placeholder="Attribute" [(ngModel)]="newAttribute.name">
+              <input [class.text-danger]="!attributeNameValid(newAttribute)" 
placeholder="{{ getMessage('edit_identity_html@attribute') }}" 
[(ngModel)]="newAttribute.name">
             </div>
             <div class="col-sm">
 
@@ -274,7 +274,7 @@
                 <option value="0">{{ getMessage("edit_identity_html@plain") 
}}</option>
                 <option value="1">{{ 
getMessage("edit_identity_html@credential") }}</option>
               </select>
-              <input *ngIf="newAttribute.flag == '0'" placeholder="Value" 
[class.text-danger]="!attributeValueValid(newAttribute)" 
[(ngModel)]="newAttribute.value">
+              <input *ngIf="newAttribute.flag == '0'" placeholder="{{ 
getMessage('Value') }}" 
[class.text-danger]="!attributeValueValid(newAttribute)" 
[(ngModel)]="newAttribute.value">
               <select *ngIf="newAttribute.flag == '1'" class="custom-select"
                 (change)="newAttribute.credential=$event.target.value; " >
                 <option value="">{{ 
getMessage("edit_identity_html@selectSource") }}</option>
diff --git a/src/app/edit-identity/edit-identity.component.ts 
b/src/app/edit-identity/edit-identity.component.ts
index 3a05cad..50c8ae9 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -13,8 +13,7 @@ import { from, forkJoin, EMPTY } from 'rxjs';
 import { Authorization } from '../authorization';
 import { IdProvider } from '../idProvider';
 import { ConfigService } from '../config.service';
-
-declare var chrome: any;
+import { LocalesService } from '../locales.service';
 
 @Component({
   selector: 'app-edit-identity',
@@ -57,6 +56,7 @@ export class EditIdentityComponent implements OnInit {
               private namestoreService: NamestoreService,
               private activatedRoute: ActivatedRoute,
               private configService: ConfigService,
+              private localesService: LocalesService,
               private router: Router,) {}
 
   ngOnInit() {
@@ -538,13 +538,7 @@ export class EditIdentityComponent implements OnInit {
 
   //Internationalization
   getMessage(key, sub?){
-    var usrAgent = navigator.userAgent;
-    if (usrAgent.indexOf("Firefox") > -1){
-      return browser.i18n.getMessage(key, sub);
-    }
-    else if (usrAgent.indexOf("Chrome") > -1){
-      return chrome.i18n.getMessage(key, sub);
-    }
+    return this.localesService.getMessage(key, sub);
   }
 
 }
diff --git a/src/app/identity-list/identity-list.component.html 
b/src/app/identity-list/identity-list.component.html
index 79160e8..7e4a7b5 100644
--- a/src/app/identity-list/identity-list.component.html
+++ b/src/app/identity-list/identity-list.component.html
@@ -13,7 +13,7 @@
   <!-- Identity search -->
   <div class="form-inline" style="display: table; margin: auto;">
     <div class="search-wrapper">
-    <input class="form-control mr-sm-2" type="search" [(ngModel)]="searchTerm" 
name="searchTerm" placeholder="Search identities" style="border-radius: 2em;">
+    <input class="form-control mr-sm-2" type="search" [(ngModel)]="searchTerm" 
name="searchTerm" placeholder="{{ 
getMessage('identity_list_html@searchbarPlaceholder') }}" style="border-radius: 
2em;">
     </div>
     <button class="btn btn-primary" [routerLink]="['/new-identity']" >
       <span class="fa fa-user-plus"></span> {{ 
getMessage("identity_list_html@newId") }}
diff --git a/src/app/identity-list/identity-list.component.ts 
b/src/app/identity-list/identity-list.component.ts
index e169427..273afba 100644
--- a/src/app/identity-list/identity-list.component.ts
+++ b/src/app/identity-list/identity-list.component.ts
@@ -10,10 +10,10 @@ import { NamestoreService } from '../namestore.service';
 import { OpenIdService } from '../open-id.service';
 import { ReclaimService } from '../reclaim.service';
 import { ModalService } from '../modal.service';
+import { LocalesService } from '../locales.service';
 import { finalize } from 'rxjs/operators';
 import { from, forkJoin, EMPTY } from 'rxjs';
 
-declare var chrome: any;
 
 @Component({
   selector: 'app-identity-list',
@@ -47,6 +47,7 @@ export class IdentityListComponent implements OnInit {
     private namestoreService: NamestoreService,
     private gnsService: GnsService,
     private modalService: ModalService,
+    private localesService: LocalesService,
     private router: Router,) {
   }
 
@@ -484,12 +485,6 @@ export class IdentityListComponent implements OnInit {
 
   //Internationalization
   getMessage(key, sub?){
-    var usrAgent = navigator.userAgent;
-    if (usrAgent.indexOf("Firefox") > -1){
-      return browser.i18n.getMessage(key, sub);
-    }
-    else if (usrAgent.indexOf("Chrome") > -1){
-      return chrome.i18n.getMessage(key, sub);
-    }
+    return this.localesService.getMessage(key, sub);
   }
 }
diff --git a/src/app/locales.service.spec.ts b/src/app/locales.service.spec.ts
new file mode 100644
index 0000000..304e4e8
--- /dev/null
+++ b/src/app/locales.service.spec.ts
@@ -0,0 +1,16 @@
+import { TestBed } from '@angular/core/testing';
+
+import { LocalesService } from './locales.service';
+
+describe('LocalesService', () => {
+  let service: LocalesService;
+
+  beforeEach(() => {
+    TestBed.configureTestingModule({});
+    service = TestBed.inject(LocalesService);
+  });
+
+  it('should be created', () => {
+    expect(service).toBeTruthy();
+  });
+});
diff --git a/src/app/locales.service.ts b/src/app/locales.service.ts
new file mode 100644
index 0000000..27c63b9
--- /dev/null
+++ b/src/app/locales.service.ts
@@ -0,0 +1,26 @@
+import { Injectable } from '@angular/core';
+
+@Injectable({
+  providedIn: 'root'
+})
+
+
+export class LocalesService {
+  
+
+  constructor() { }
+
+    //Internationalization
+    getMessage(key, sub?){
+      var usrAgent = navigator.userAgent;
+      if (usrAgent.indexOf("Firefox") > -1){
+        return browser.i18n.getMessage(key, sub);
+      }
+      else if (usrAgent.indexOf("Chrome") > -1){
+        return chrome.i18n.getMessage(key, sub);
+      }
+      else {
+        return key;
+      }
+    }
+}
diff --git a/src/app/new-identity/new-identity.component.ts 
b/src/app/new-identity/new-identity.component.ts
index 51e0782..aed48e3 100644
--- a/src/app/new-identity/new-identity.component.ts
+++ b/src/app/new-identity/new-identity.component.ts
@@ -2,8 +2,7 @@ import { Component, OnInit } from '@angular/core';
 import { Router } from '@angular/router';
 import { Identity } from '../identity';
 import { IdentityService } from '../identity.service';
-
-declare var chrome: any;
+import { LocalesService } from '../locales.service';
 
 @Component({
   selector: 'app-new-identity',
@@ -16,6 +15,7 @@ export class NewIdentityComponent implements OnInit {
   identities: Identity[];
 
   constructor(private identityService: IdentityService,
+              private localesService: LocalesService,
               private router: Router) { }
 
   ngOnInit() {
@@ -84,13 +84,7 @@ export class NewIdentityComponent implements OnInit {
 
   //Internationalization
   getMessage(key, sub?){
-    var usrAgent = navigator.userAgent;
-    if (usrAgent.indexOf("Firefox") > -1){
-      return browser.i18n.getMessage(key, sub);
-    }
-    else if (usrAgent.indexOf("Chrome") > -1){
-      return chrome.i18n.getMessage(key, sub);
-    }
+    return this.localesService.getMessage(key, sub);
   }
 
 }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]