mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-01 11:52:15 +00:00
* i18n interceptor, set language to browser lang * nullcheck * rm external idp log * fix module imports, rm user displayname from i18n * Update console/src/assets/i18n/de.json Co-authored-by: Fabi <[email protected]>
28 lines
852 B
TypeScript
28 lines
852 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import { Request, UnaryInterceptor, UnaryResponse } from 'grpc-web';
|
|
|
|
|
|
const i18nHeader = 'Accept-Language';
|
|
@Injectable({ providedIn: 'root' })
|
|
/**
|
|
* Set the navigator language as header to all grpc requests
|
|
*/
|
|
export class I18nInterceptor<TReq = unknown, TResp = unknown> implements UnaryInterceptor<TReq, TResp> {
|
|
constructor() { }
|
|
|
|
public async intercept(request: Request<TReq, TResp>, invoker: any): Promise<UnaryResponse<TReq, TResp>> {
|
|
const metadata = request.getMetadata();
|
|
|
|
const navLang = navigator.language;
|
|
if (navLang) {
|
|
metadata[i18nHeader] = navLang;
|
|
}
|
|
|
|
return invoker(request).then((response: any) => {
|
|
return response;
|
|
}).catch((error: any) => {
|
|
return Promise.reject(error);
|
|
});
|
|
}
|
|
}
|