mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
26 lines
749 B
Go
26 lines
749 B
Go
package middleware
|
|
|
|
import (
|
|
"context"
|
|
|
|
"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 := newZitadelTranslator(authz.GetInstance(ctx).DefaultLanguage())
|
|
if loc, ok := resp.(localizers); ok && resp != nil {
|
|
translateFields(ctx, loc, translator)
|
|
}
|
|
if err != nil {
|
|
err = translateError(ctx, err, translator)
|
|
}
|
|
return resp, err
|
|
}
|
|
}
|