From acae7d827c82d0554be659cc2760e323bd2d74c1 Mon Sep 17 00:00:00 2001 From: Rene Vergara A Date: Fri, 27 Jan 2023 18:05:55 -0500 Subject: [PATCH] Internationalization process starting --- languages.csv | 13 ++++++++ src/app/language.service.spec.ts | 16 ++++++++++ src/app/language.service.ts | 48 ++++++++++++++++++++++++++++ src/app/login/login.component.html | 10 +++--- src/app/login/login.component.ts | 50 ++++++++++++++++++++++++++++-- src/app/viewelement.model.ts | 3 ++ 6 files changed, 133 insertions(+), 7 deletions(-) create mode 100644 languages.csv create mode 100644 src/app/language.service.spec.ts create mode 100644 src/app/language.service.ts create mode 100644 src/app/viewelement.model.ts diff --git a/languages.csv b/languages.csv new file mode 100644 index 0000000..fdef528 --- /dev/null +++ b/languages.csv @@ -0,0 +1,13 @@ +"encode_id","view_name","view_element","view_element_text" +"en-US","login","login_confirm_login","ZGo confirms your login on the Zcash blockhain" +"en-US","login","login_connect_to_zgo","Connect your wallet to ZGo" +"en-US","login","login_enter_pin","Enter the PIN sent by ZGo to confirm wallet ownership:" +"en-US","login","login_last_block","Last block seen:" +"en-US","login","login_link_wallet","Link Wallet" +"en-US","main","main_price_data","Price data provided by CoinGecko API" +"es-US","login","login_confirm_login","ZGo confirma su ingreso en la cadena de Zcash" +"es-US","login","login_connect_to_zgo","Conectar su billetera a ZGo" +"es-US","login","login_enter_pin","Ingrese el PIN enviado por ZGo para confirmar su billetera:" +"es-US","login","login_last_block","Ultimo Bloque Verificado: " +"es-US","login","login_link_wallet","Asociar Billetera" +"es-US","main","main_price_data","Precios provistos por API de CoinGecko" diff --git a/src/app/language.service.spec.ts b/src/app/language.service.spec.ts new file mode 100644 index 0000000..299455e --- /dev/null +++ b/src/app/language.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { LanguageService } from './language.service'; + +describe('LanguageService', () => { + let service: LanguageService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(LanguageService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/language.service.ts b/src/app/language.service.ts new file mode 100644 index 0000000..21a91d7 --- /dev/null +++ b/src/app/language.service.ts @@ -0,0 +1,48 @@ +import { Injectable } from '@angular/core'; +import { viewElement } from './viewelement.model'; +import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http'; + +import { ConfigData } from './configdata'; + +@Injectable({ + providedIn: 'root' +}) + +export class LanguageService { + + private baseURL = 'http://www.test.com/getlang'; + + constructor(private http:HttpClient) { + } + + httpOptions = { + headers: new HttpHeaders({ + 'Content-Type': 'application/json' + }) + }; + + _getViewElements ( viewName:string, + encoding:string = 'en-US' ){ + + + const vElem : string = '{' + + '"login_confirm_login":"ZGo confirma su ingreso en la cadena de Zcash"' + ',' + + '"login_connect_to_zgo":"Conectar su billetera a ZGo"' + ',' + + '"login_enter_pin":"Ingrese el PIN enviado por ZGo para confirmar su billetera:"' + ',' + + '"login_last_block":"Ultimo Bloque Verificado: "' + ',' + + '"login_link_wallet":"Asociar Billetera"' + '}'; + + return vElem; + + } + + getViewElements ( viewName:string, + encoding:string = 'en-US' ) { + + return this.http.get(this.baseURL + + '/?lang_id=' + encoding + + '&viewname=' + viewName); + + } + +} diff --git a/src/app/login/login.component.html b/src/app/login/login.component.html index b43b3de..74a4589 100644 --- a/src/app/login/login.component.html +++ b/src/app/login/login.component.html @@ -1,32 +1,32 @@
-

Last block seen: {{ heightUpdate | async }}

+

{{ vE.loginLastBlock }}{{ heightUpdate | async }}

The Zcash Register

- +
- +

{{barMessage}}

- +

Check your wallet diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index aa96ced..27856c1 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -8,15 +8,25 @@ import { UserService } from '../user.service'; import { FullnodeService } from '../fullnode.service'; import { ScanComponent} from '../scan/scan.component'; import { Tx } from '../tx.model'; -import {User} from '../user.model'; +import { User } from '../user.model'; import { Owner } from '../owner.model'; import { Subscription, Observable } from 'rxjs'; import { take } from 'rxjs/operators'; import { v4 as uuidv4 } from 'uuid'; + +import { LanguageService } from '../language.service'; + var QRCode = require('easyqrcodejs'); var URLSafeBase64 = require('urlsafe-base64'); var Buffer = require('buffer/').Buffer; +interface _vE_login { + login_confirm_login : string, + login_connect_to_zgo : string, + login_enter_pin : string, + login_last_block : string, + login_link_wallet : string +} @Component({ selector: 'app-login', @@ -82,6 +92,21 @@ export class LoginComponent implements OnInit, AfterViewInit { entryForm: UntypedFormGroup; pinForm: UntypedFormGroup; + public vResponse : _vE_login = { + login_confirm_login : '', + login_connect_to_zgo : '', + login_enter_pin : '', + login_last_block : '', + login_link_wallet : '' + }; + + public vE = { + loginConfirmLogin : '', + loginConnectToZGo : '', + loginEnterPin : '', + loginLastBlock : '', + loginLinkWallet : '' + } constructor( private fb: UntypedFormBuilder, @@ -90,7 +115,8 @@ export class LoginComponent implements OnInit, AfterViewInit { private router: Router, public userService: UserService, private dialog: MatDialog, - private _changeDetectorRef: ChangeDetectorRef + private _changeDetectorRef: ChangeDetectorRef, + private languageService: LanguageService ){ //this.fullnodeService.getAddr(); this.entryForm = fb.group({ @@ -116,6 +142,7 @@ export class LoginComponent implements OnInit, AfterViewInit { } ngAfterViewInit(){ + //console.log('Step', this.myStepper); this.pinError = false; //console.log('Activated route data in Component:::', this.activatedRoute.data); @@ -135,6 +162,25 @@ export class LoginComponent implements OnInit, AfterViewInit { } ngOnInit(){ + + this.languageService.getViewElements('login','es-US').subscribe( + response => { + console.log('Received >> ', response ); + var xv = JSON.parse(response) as _vE_login; + + console.log('Last block -> ', ); +/* this.vE.loginLastBlock = vElemObject.login_last_block; + + this.vE.loginConnectToZGo = vElemObject.login_connect_to_zgo; + this.vE.loginLinkWallet = vElemObject.login_link_wallet; + this.vE.loginConfirmLogin = vElemObject.login_confirm_login; + this.vE.loginEnterPin = vElemObject.login_enter_pin; +*/ + }, + error => { console.log('Error >> ',error); } + ); + + this.intervalHolder = setInterval(() => { this.fullnodeService.getHeight(); //this.userService.findUser(); diff --git a/src/app/viewelement.model.ts b/src/app/viewelement.model.ts new file mode 100644 index 0000000..47fbeda --- /dev/null +++ b/src/app/viewelement.model.ts @@ -0,0 +1,3 @@ +export interface viewElement { + text: string; +}