UI language management: Version 1.02 - access to language data from server enabled
This commit is contained in:
parent
d93c95558f
commit
d14f47cc8b
2 changed files with 22 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
|||
export interface LanguageData {
|
||||
_id: string;
|
||||
language: string;
|
||||
component: string;
|
||||
data?: any;
|
||||
|
|
|
@ -3,13 +3,22 @@ import { LanguageData } from './language.model';
|
|||
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
|
||||
import { ConfigData } from './configdata';
|
||||
|
||||
var Buffer = require('buffer/').Buffer;
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
|
||||
export class LanguageService {
|
||||
|
||||
private baseURL = 'http://localhost:8080/getlang';
|
||||
//
|
||||
// URL for test using REST API to local MariaDB database
|
||||
// private baseURL = 'http://localhost:8080/zgointl';
|
||||
//
|
||||
// URL for test using REST API to local MongoDB database
|
||||
// private baseURL = 'http://localhost:5000/zgointl';
|
||||
//
|
||||
// URL for access MongoDB database from remote server
|
||||
private baseURL = ConfigData.Be_URL + 'api/getlang';
|
||||
|
||||
public zgoLanguage: string = '';
|
||||
|
||||
|
@ -20,7 +29,12 @@ export class LanguageService {
|
|||
//
|
||||
// Get default language from localStorage
|
||||
//
|
||||
var def_zgoLanguage = localStorage.getItem('zgo_language');
|
||||
const def_zgoLanguage = localStorage.getItem('zgo_language');
|
||||
//
|
||||
// Set authorizacion paramaters
|
||||
//
|
||||
const Auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64');
|
||||
const reqHeaders = new HttpHeaders().set('Authorization', Auth);
|
||||
|
||||
if ( def_zgoLanguage == null ) {
|
||||
this.zgoLanguage = 'en-US';
|
||||
|
@ -29,10 +43,11 @@ export class LanguageService {
|
|||
this.zgoLanguage = def_zgoLanguage;
|
||||
}
|
||||
//
|
||||
// Get View's text data from language database
|
||||
// Get component's text data from language database
|
||||
//
|
||||
return this.http.get<LanguageData>(this.baseURL +
|
||||
'/?lang_id=' + this.zgoLanguage +
|
||||
'&viewname=' + viewName);
|
||||
'/?lang=' + this.zgoLanguage +
|
||||
'&component=' + viewName,
|
||||
{ headers : reqHeaders });
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue