feat: localized messages (#328)

* fix: project by id loads project from view and from eventstore

* fix: correct search key for role

* feat(auth): my user changes

* fix: improve error handling in change converters

* fix: log-id

* feat(translations): event type translations

* feat: localized translations

* fix(translations): correct yaml format

* chore: example

* fix: remove unused code

* correct checkSSL in sql

* chore(modules): update

* chore: refactor interceptors

* fix: improvments

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/en.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/en.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/en.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/en.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/en.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/de.yaml

Co-authored-by: Florian Forster <[email protected]>

* Update internal/static/i18n/en.yaml

Co-authored-by: Florian Forster <[email protected]>

* chore(translations): start with upper case on Code

* chore(middleware): move funcs

* add message to grpc web generation

* translation in mgmt and fixes

* fix authoptions

* fix console statik

Co-authored-by: Florian Forster <[email protected]>
Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
Silvan
2020-07-08 09:48:11 +02:00
committed by GitHub
co-authored by Florian Forster Livio Amstutz
parent b863e7c407
commit c0f85c2733
40 changed files with 17383 additions and 18102 deletions
+2144 -3886
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+14 -61
View File
@@ -621,7 +621,7 @@
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/protobufStruct"
"type": "object"
}
}
},
@@ -632,19 +632,6 @@
}
},
"definitions": {
"protobufListValue": {
"type": "object",
"properties": {
"values": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufValue"
},
"description": "Repeated field of dynamically typed values."
}
},
"description": "`ListValue` is a wrapper around a repeated field of values.\n\nThe JSON representation for `ListValue` is JSON array."
},
"protobufNullValue": {
"type": "string",
"enum": [
@@ -653,51 +640,6 @@
"default": "NULL_VALUE",
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\n The JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
},
"protobufStruct": {
"type": "object",
"properties": {
"fields": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/protobufValue"
},
"description": "Unordered map of dynamically typed values."
}
},
"description": "`Struct` represents a structured data value, consisting of fields\nwhich map to dynamically typed values. In some languages, `Struct`\nmight be supported by a native representation. For example, in\nscripting languages like JS a struct is represented as an\nobject. The details of that representation are described together\nwith the proto support for the language.\n\nThe JSON representation for `Struct` is JSON object."
},
"protobufValue": {
"type": "object",
"properties": {
"null_value": {
"$ref": "#/definitions/protobufNullValue",
"description": "Represents a null value."
},
"number_value": {
"type": "number",
"format": "double",
"description": "Represents a double value."
},
"string_value": {
"type": "string",
"description": "Represents a string value."
},
"bool_value": {
"type": "boolean",
"format": "boolean",
"description": "Represents a boolean value."
},
"struct_value": {
"$ref": "#/definitions/protobufStruct",
"description": "Represents a structured value."
},
"list_value": {
"$ref": "#/definitions/protobufListValue",
"description": "Represents a repeated `Value`."
}
},
"description": "`Value` represents a dynamically typed value which can be either\nnull, a number, a string, a boolean, a recursive struct value, or a\nlist of values. A producer of value is expected to set one of that\nvariants, absence of any variant indicates an error.\n\nThe JSON representation for `Value` is JSON value."
},
"v1Change": {
"type": "object",
"properties": {
@@ -706,7 +648,7 @@
"format": "date-time"
},
"event_type": {
"type": "string"
"$ref": "#/definitions/v1LocalizedMessage"
},
"sequence": {
"type": "string",
@@ -719,7 +661,7 @@
"type": "string"
},
"data": {
"$ref": "#/definitions/protobufStruct"
"type": "object"
}
}
},
@@ -752,6 +694,17 @@
],
"default": "GENDER_UNSPECIFIED"
},
"v1LocalizedMessage": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"localized_message": {
"type": "string"
}
}
},
"v1MFAState": {
"type": "string",
"enum": [
+11
View File
@@ -0,0 +1,11 @@
package grpc
import "github.com/caos/zitadel/internal/api/grpc/server/middleware"
func (c *Changes) Localizers() []middleware.Localizer {
localizers := make([]middleware.Localizer, len(c.Changes))
for i, change := range c.Changes {
localizers[i] = change.EventType
}
return localizers
}
+1 -1
View File
@@ -1,4 +1,4 @@
package grpc
//go:generate protoc -I$GOPATH/src -I../proto -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I${GOPATH}/src/github.com/envoyproxy/protoc-gen-validate -I${GOPATH}/src/github.com/caos/zitadel/internal/protoc/protoc-gen-authoption --go_out=plugins=grpc:$GOPATH/src --grpc-gateway_out=logtostderr=true:$GOPATH/src --swagger_out=logtostderr=true:. --authoption_out=. ../proto/auth.proto
//go:generate protoc -I${GOPATH}/src -I../proto -I${GOPATH}/src/github.com/caos/zitadel/pkg/message -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I${GOPATH}/src/github.com/envoyproxy/protoc-gen-validate -I${GOPATH}/src/github.com/caos/zitadel/internal/protoc/protoc-gen-authoption --go_out=plugins=grpc:${GOPATH}/src --grpc-gateway_out=logtostderr=true:${GOPATH}/src --swagger_out=logtostderr=true:. --authoption_out=. ../proto/auth.proto
//go:generate mockgen -package api -destination ./mock/auth.proto.mock.go github.com/caos/zitadel/pkg/auth/api/grpc AuthServiceClient
+1
View File
@@ -41,6 +41,7 @@ func (s *Server) GRPCServer(defaults systemdefaults.SystemDefaults) (*grpc.Serve
grpc.UnaryInterceptor(
grpc_middleware.ChainUnaryServer(
middleware.ErrorHandler(defaults.DefaultLanguage),
middleware.TranslationHandler(defaults.DefaultLanguage),
AuthService_Authorization_Interceptor(s.verifier, &s.authZ),
),
),
+4 -4
View File
@@ -8,6 +8,7 @@ import (
"github.com/caos/zitadel/internal/api/auth"
"github.com/caos/zitadel/internal/eventstore/models"
usr_model "github.com/caos/zitadel/internal/user/model"
message "github.com/caos/zitadel/pkg/message"
"github.com/golang/protobuf/ptypes"
"golang.org/x/text/language"
"google.golang.org/protobuf/encoding/protojson"
@@ -343,11 +344,11 @@ func userChangesToResponse(response *usr_model.UserChanges, offset uint64, limit
return &Changes{
Limit: limit,
Offset: offset,
Changes: userChangesToMgtAPI(response),
Changes: userChangesToAPI(response),
}
}
func userChangesToMgtAPI(changes *usr_model.UserChanges) (_ []*Change) {
func userChangesToAPI(changes *usr_model.UserChanges) (_ []*Change) {
result := make([]*Change, len(changes.Changes))
for i, change := range changes.Changes {
@@ -358,10 +359,9 @@ func userChangesToMgtAPI(changes *usr_model.UserChanges) (_ []*Change) {
err = protojson.Unmarshal(changedData, data)
logging.Log("GRPC-0kRsY").OnError(err).Debug("unable to marshal changed data to struct")
}
result[i] = &Change{
ChangeDate: change.ChangeDate,
EventType: change.EventType,
EventType: message.NewLocalizedEventType(change.EventType),
Sequence: change.Sequence,
Data: data,
EditorId: change.ModifierId,
+2 -1
View File
@@ -7,6 +7,7 @@ import "google/protobuf/timestamp.proto";
import "validate/validate.proto";
import "protoc-gen-swagger/options/annotations.proto";
import "authoption/options.proto";
import "message.proto";
package caos.zitadel.auth.api.v1;
@@ -668,7 +669,7 @@ message Changes {
message Change {
google.protobuf.Timestamp change_date = 1;
string event_type = 2;
caos.zitadel.api.v1.LocalizedMessage event_type = 2;
uint64 sequence = 3;
string editor_id = 4;
string editor = 5;