mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-31 19:42:15 +00:00
fix(console): intercept navigator.language, set browser lang as default for user without explicit setting, user table outline, member create dialog import (#820)
* 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]>
This commit is contained in:
@@ -9,6 +9,7 @@ import { AuthServicePromiseClient } from '../proto/generated/auth_grpc_web_pb';
|
||||
import { ManagementServicePromiseClient } from '../proto/generated/management_grpc_web_pb';
|
||||
import { AuthenticationService } from './authentication.service';
|
||||
import { AuthInterceptor } from './interceptors/auth.interceptor';
|
||||
import { I18nInterceptor } from './interceptors/i18n.interceptor';
|
||||
import { OrgInterceptor } from './interceptors/org.interceptor';
|
||||
import { StorageService } from './storage.service';
|
||||
|
||||
@@ -37,6 +38,7 @@ export class GrpcService {
|
||||
unaryInterceptors: [
|
||||
new OrgInterceptor(this.storageService),
|
||||
new AuthInterceptor(this.authenticationService, this.storageService, this.dialog),
|
||||
new I18nInterceptor(),
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user