mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 19:44:21 +00:00
24 lines
647 B
Go
24 lines
647 B
Go
|
package middleware
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"golang.org/x/text/language"
|
||
|
|
||
|
"google.golang.org/grpc"
|
||
|
|
||
|
_ "github.com/caos/zitadel/internal/statik"
|
||
|
)
|
||
|
|
||
|
func TranslationHandler(defaultLanguage language.Tag) func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||
|
translator := newZitadelTranslator(defaultLanguage)
|
||
|
|
||
|
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||
|
resp, err := handler(ctx, req)
|
||
|
if loc, ok := resp.(localizers); ok {
|
||
|
translateFields(ctx, loc, translator)
|
||
|
}
|
||
|
return resp, err
|
||
|
}
|
||
|
}
|