mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
9271623ec9
* fix: load auth users * fix: add triggerbulk * fix: build pre-release * fix even more french translations * fix: build version Co-authored-by: Livio Spring <livio.a@gmail.com>
31 lines
929 B
Go
31 lines
929 B
Go
package middleware
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/logging"
|
|
"google.golang.org/grpc"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
|
|
_ "github.com/zitadel/zitadel/internal/statik"
|
|
)
|
|
|
|
func TranslationHandler() func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
|
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
|
resp, err := handler(ctx, req)
|
|
translator, translatorError := newZitadelTranslator(authz.GetInstance(ctx).DefaultLanguage())
|
|
if translatorError != nil {
|
|
logging.New().WithError(translatorError).Error("could not load translator")
|
|
return resp, err
|
|
}
|
|
if loc, ok := resp.(localizers); ok && resp != nil {
|
|
translateFields(ctx, loc, translator)
|
|
}
|
|
if err != nil {
|
|
err = translateError(ctx, err, translator)
|
|
}
|
|
return resp, err
|
|
}
|
|
}
|