From 90bd1fc40383f78e2a165e0a4fb5b96d5f88f43d Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Thu, 1 Aug 2024 17:01:38 +0200 Subject: [PATCH] the translator added to handlers --- services/activitylog/pkg/service/http.go | 8 +- services/graph/Makefile | 6 +- .../pkg/{service/v0 => }/l10n/.tx/config | 0 .../l10n/locale/bg/LC_MESSAGES/graph.po | 0 .../l10n/locale/de/LC_MESSAGES/graph.po | 0 .../l10n/locale/en_GB/LC_MESSAGES/graph.po | 0 .../l10n/locale/es/LC_MESSAGES/graph.po | 0 .../l10n/locale/fr/LC_MESSAGES/graph.po | 0 .../l10n/locale/fr_FR/LC_MESSAGES/graph.po | 0 .../l10n/locale/ja_JP/LC_MESSAGES/graph.po | 0 .../l10n/locale/ko/LC_MESSAGES/graph.po | 0 .../l10n/locale/nl/LC_MESSAGES/graph.po | 0 .../l10n/locale/pt_BR/LC_MESSAGES/graph.po | 0 .../l10n/locale/ru/LC_MESSAGES/graph.po | 39 +++++++++- .../l10n/locale/ru_RU/LC_MESSAGES/graph.po | 0 .../l10n/locale/sq/LC_MESSAGES/graph.po | 0 .../l10n/locale/tr/LC_MESSAGES/graph.po | 0 .../l10n/locale/vi/LC_MESSAGES/graph.po | 0 .../l10n/locale/zh/LC_MESSAGES/graph.po | 0 .../l10n/locale/zh_HK/LC_MESSAGES/graph.po | 0 services/graph/pkg/l10n/translation.go | 30 +++++++ .../service/v0/api_driveitem_permissions.go | 34 ++++++++ .../graph/pkg/service/v0/spacetemplates.go | 13 +--- services/graph/pkg/unifiedrole/unifiedrole.go | 78 ++++++++++++++----- 24 files changed, 169 insertions(+), 39 deletions(-) rename services/graph/pkg/{service/v0 => }/l10n/.tx/config (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/bg/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/de/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/en_GB/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/es/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/fr/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/fr_FR/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/ja_JP/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/ko/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/nl/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/pt_BR/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/ru/LC_MESSAGES/graph.po (51%) rename services/graph/pkg/{service/v0 => }/l10n/locale/ru_RU/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/sq/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/tr/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/vi/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/zh/LC_MESSAGES/graph.po (100%) rename services/graph/pkg/{service/v0 => }/l10n/locale/zh_HK/LC_MESSAGES/graph.po (100%) create mode 100644 services/graph/pkg/l10n/translation.go diff --git a/services/activitylog/pkg/service/http.go b/services/activitylog/pkg/service/http.go index d47e2e7181..5efe366512 100644 --- a/services/activitylog/pkg/service/http.go +++ b/services/activitylog/pkg/service/http.go @@ -85,6 +85,10 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h return } + // FIXME: configurable default locale? + loc := l10n.MustGetUserLocale(r.Context(), activeUser.GetId().GetOpaqueId(), r.Header.Get(l10n.HeaderAcceptLanguage), s.valService) + t := l10n.NewTranslatorFromCommonConfig("en", _domain, "", _localeFS, _localeSubPath) + resp := GetActivitiesResponse{Activities: make([]libregraph.Activity, 0, len(evRes.GetEvents()))} for _, e := range evRes.GetEvents() { delete(toDelete, e.GetId()) @@ -164,10 +168,6 @@ func (s *ActivitylogService) HandleGetItemActivities(w http.ResponseWriter, r *h continue } - // FIXME: configurable default locale? - loc := l10n.MustGetUserLocale(r.Context(), activeUser.GetId().GetOpaqueId(), r.Header.Get(l10n.HeaderAcceptLanguage), s.valService) - t := l10n.NewTranslatorFromCommonConfig("en", _domain, "", _localeFS, _localeSubPath) - resp.Activities = append(resp.Activities, NewActivity(t.Translate(message, loc), ts, e.GetId(), vars)) } diff --git a/services/graph/Makefile b/services/graph/Makefile index 60a640b069..2119f6ed5f 100644 --- a/services/graph/Makefile +++ b/services/graph/Makefile @@ -2,8 +2,8 @@ SHELL := bash NAME := graph # Where to write the files generated by this makefile. -OUTPUT_DIR = ./pkg/service/v0/l10n -TEMPLATE_FILE = ./pkg/service/v0/l10n/graph.pot +OUTPUT_DIR = ./pkg/l10n +TEMPLATE_FILE = ./pkg/l10n/graph.pot include ../../.make/recursion.mk @@ -45,7 +45,7 @@ l10n-push: .PHONY: l10n-read l10n-read: $(GO_XGETTEXT) - go-xgettext -o $(OUTPUT_DIR)/graph.pot --keyword=l10n.Template --add-comments -s pkg/service/v0/spacetemplates.go + go-xgettext -o $(OUTPUT_DIR)/graph.pot --keyword=l10n.Template --add-comments -s pkg/service/v0/spacetemplates.go -s pkg/unifiedrole/unifiedrole.go .PHONY: l10n-write l10n-write: diff --git a/services/graph/pkg/service/v0/l10n/.tx/config b/services/graph/pkg/l10n/.tx/config similarity index 100% rename from services/graph/pkg/service/v0/l10n/.tx/config rename to services/graph/pkg/l10n/.tx/config diff --git a/services/graph/pkg/service/v0/l10n/locale/bg/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/bg/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/bg/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/bg/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/de/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/de/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/de/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/de/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/en_GB/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/en_GB/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/en_GB/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/en_GB/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/es/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/es/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/es/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/es/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/fr/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/fr/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/fr/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/fr/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/fr_FR/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/fr_FR/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/fr_FR/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/fr_FR/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/ja_JP/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/ja_JP/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/ja_JP/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/ja_JP/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/ko/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/ko/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/ko/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/ko/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/nl/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/nl/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/nl/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/nl/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/pt_BR/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/pt_BR/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/pt_BR/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/pt_BR/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/ru/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/ru/LC_MESSAGES/graph.po similarity index 51% rename from services/graph/pkg/service/v0/l10n/locale/ru/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/ru/LC_MESSAGES/graph.po index 0eea275dc2..e10f76e467 100644 --- a/services/graph/pkg/service/v0/l10n/locale/ru/LC_MESSAGES/graph.po +++ b/services/graph/pkg/l10n/locale/ru/LC_MESSAGES/graph.po @@ -2,10 +2,10 @@ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. -# +# # Translators: # Alex , 2024 -# +# #, fuzzy msgid "" msgstr "" @@ -25,3 +25,38 @@ msgstr "" #: pkg/service/v0/spacetemplates.go:37 msgid "Here you can add a description for this Space." msgstr "Здесь вы можете добавить описание этого пространства." + +#: pkg/unifiedrole/unifiedrole.go:87 +msgid "Can edit" +msgstr "" + +#. UnifiedRole Viewer, Role DisplayName (resolves directly) +#: pkg/unifiedrole/unifiedrole.go:79 +msgid "Can view" +msgstr "" + +#. default description for new spaces +#: pkg/service/v0/spacetemplates.go:31 +msgid "Here you can add a description for this Space." +msgstr "" + +#. UnifiedRole Viewer, Role Description (resolves directly) +#. UnifiedRole SpaceViewer, Role Description (resolves directly) +#: pkg/unifiedrole/unifiedrole.go:77 pkg/unifiedrole/unifiedrole.go:82 +msgid "View and download." +msgstr "" + +#: pkg/unifiedrole/unifiedrole.go:91 +msgid "View, download and edit." +msgstr "" + +#: pkg/unifiedrole/unifiedrole.go:92 +msgid "View, download and upload." +msgstr "" + +#. canEdit := "Can edit" +#. UnifiedRole Editor, Role Description (resolves directly) +#. UnifiedRole SpaseEditor, Role Description (resolves directly) +#: pkg/unifiedrole/unifiedrole.go:86 pkg/unifiedrole/unifiedrole.go:90 +msgid "View, download, upload, edit, add and delete." +msgstr "" diff --git a/services/graph/pkg/service/v0/l10n/locale/ru_RU/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/ru_RU/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/ru_RU/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/ru_RU/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/sq/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/sq/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/sq/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/sq/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/tr/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/tr/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/tr/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/tr/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/vi/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/vi/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/vi/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/vi/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/zh/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/zh/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/zh/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/zh/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/service/v0/l10n/locale/zh_HK/LC_MESSAGES/graph.po b/services/graph/pkg/l10n/locale/zh_HK/LC_MESSAGES/graph.po similarity index 100% rename from services/graph/pkg/service/v0/l10n/locale/zh_HK/LC_MESSAGES/graph.po rename to services/graph/pkg/l10n/locale/zh_HK/LC_MESSAGES/graph.po diff --git a/services/graph/pkg/l10n/translation.go b/services/graph/pkg/l10n/translation.go new file mode 100644 index 0000000000..ded91ade6b --- /dev/null +++ b/services/graph/pkg/l10n/translation.go @@ -0,0 +1,30 @@ +package l10n + +import ( + "embed" + + l10npkg "github.com/owncloud/ocis/v2/ocis-pkg/l10n" +) + +var ( + //go:embed locale + _localeFS embed.FS +) + +const ( + // subfolder where the translation files are stored + _localeSubPath = "locale" + + // domain of the graph service (transifex) + _domain = "graph" +) + +func Translate(content, locale, defaultLocale string) string { + t := l10npkg.NewTranslatorFromCommonConfig(defaultLocale, _domain, "", _localeFS, _localeSubPath) + return t.Translate(content, locale) +} + +func NewTranslateLocation(locale, defaultLocale string) func(string, ...any) string { + t := l10npkg.NewTranslatorFromCommonConfig(defaultLocale, _domain, "", _localeFS, _localeSubPath) + return t.Locale(locale).Get +} diff --git a/services/graph/pkg/service/v0/api_driveitem_permissions.go b/services/graph/pkg/service/v0/api_driveitem_permissions.go index 4c169b1d28..983ee06b65 100644 --- a/services/graph/pkg/service/v0/api_driveitem_permissions.go +++ b/services/graph/pkg/service/v0/api_driveitem_permissions.go @@ -25,6 +25,8 @@ import ( "github.com/go-chi/chi/v5" "github.com/go-chi/render" libregraph "github.com/owncloud/libre-graph-api-go" + "github.com/owncloud/ocis/v2/ocis-pkg/l10n" + l10n2 "github.com/owncloud/ocis/v2/services/graph/pkg/l10n" "github.com/owncloud/ocis/v2/ocis-pkg/conversions" "github.com/owncloud/ocis/v2/ocis-pkg/log" @@ -632,6 +634,22 @@ func (api DriveItemPermissionsApi) ListPermissions(w http.ResponseWriter, r *htt return } + loc := r.Header.Get(l10n.HeaderAcceptLanguage) + w.Header().Add("Content-Language", loc) + if loc != "" && loc != "en" { + trf := l10n2.NewTranslateLocation(loc, "en") + for i, role := range permissions.LibreGraphPermissionsRolesAllowedValues { + err := l10n.TranslateEntity(&role, trf, + l10n.TranslateField("Description"), + l10n.TranslateField("DisplayName")) + if err != nil { + api.logger.Warn().Err(err).Msg("tranlation error") + continue + } + permissions.LibreGraphPermissionsRolesAllowedValues[i] = role + } + } + render.Status(r, http.StatusOK) render.JSON(w, r, permissions) } @@ -653,6 +671,22 @@ func (api DriveItemPermissionsApi) ListSpaceRootPermissions(w http.ResponseWrite return } + loc := r.Header.Get(l10n.HeaderAcceptLanguage) + w.Header().Add("Content-Language", loc) + if loc != "" && loc != "en" { + trf := l10n2.NewTranslateLocation(loc, "en") + for i, role := range permissions.LibreGraphPermissionsRolesAllowedValues { + err := l10n.TranslateEntity(&role, trf, + l10n.TranslateField("Description"), + l10n.TranslateField("DisplayName")) + if err != nil { + api.logger.Warn().Err(err).Msg("tranlation error") + continue + } + permissions.LibreGraphPermissionsRolesAllowedValues[i] = role + } + } + render.Status(r, http.StatusOK) render.JSON(w, r, permissions) } diff --git a/services/graph/pkg/service/v0/spacetemplates.go b/services/graph/pkg/service/v0/spacetemplates.go index 1a7e0ea0fa..75da3a7286 100644 --- a/services/graph/pkg/service/v0/spacetemplates.go +++ b/services/graph/pkg/service/v0/spacetemplates.go @@ -15,18 +15,13 @@ import ( "github.com/cs3org/reva/v2/pkg/storagespace" "github.com/cs3org/reva/v2/pkg/utils" "github.com/owncloud/ocis/v2/ocis-pkg/l10n" + l10n_pkg "github.com/owncloud/ocis/v2/services/graph/pkg/l10n" ) var ( //go:embed spacetemplate/* _spaceTemplateFS embed.FS - //go:embed l10n/locale - _localeFS embed.FS - - // subfolder where the translation files are stored - _localeSubPath = "l10n/locale" - // name of the secret space folder _spaceFolderName = ".space" @@ -39,9 +34,6 @@ var ( // name of the readme.md file _readmeName = "readme.md" - // domain of the graph service (transifex) - _domain = "graph" - // HeaderAcceptLanguage is the header key for the accept-language header HeaderAcceptLanguage = "Accept-Language" @@ -121,10 +113,9 @@ func imageUpload(ctx context.Context, mdc *metadata.CS3) (string, error) { } func readmeUpload(ctx context.Context, mdc *metadata.CS3, locale string, defaultLocale string) (string, error) { - t := l10n.NewTranslatorFromCommonConfig(defaultLocale, _domain, "", _localeFS, _localeSubPath) res, err := mdc.Upload(ctx, metadata.UploadRequest{ Path: filepath.Join(_spaceFolderName, _readmeName), - Content: []byte(t.Translate(_readmeText, locale)), + Content: []byte(l10n_pkg.Translate(_readmeText, locale, defaultLocale)), }) if err != nil { return "", err diff --git a/services/graph/pkg/unifiedrole/unifiedrole.go b/services/graph/pkg/unifiedrole/unifiedrole.go index 4a6d5123dd..4c373b532c 100644 --- a/services/graph/pkg/unifiedrole/unifiedrole.go +++ b/services/graph/pkg/unifiedrole/unifiedrole.go @@ -7,6 +7,7 @@ import ( provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" libregraph "github.com/owncloud/libre-graph-api-go" + "github.com/owncloud/ocis/v2/ocis-pkg/l10n" "google.golang.org/protobuf/proto" "github.com/cs3org/reva/v2/pkg/conversions" @@ -71,12 +72,54 @@ var legacyNames map[string]string = map[string]string{ UnifiedRoleSecureViewerID: conversions.RoleSecureViewer, } +var ( + // UnifiedRole Viewer, Role Description (resolves directly) + _viewerUnifiedRoleDescription = l10n.Template("View and download.") + // UnifiedRole Viewer, Role DisplayName (resolves directly) + _viewerUnifiedRoleDisplayName = l10n.Template("Can view") + + // UnifiedRole SpaceViewer, Role Description (resolves directly) + _spaceViewerUnifiedRoleDescription = l10n.Template("View and download.") + // UnifiedRole SpaseViewer, Role DisplayName (resolves directly) + _spaceViewerUnifiedRoleDisplayName = l10n.Template("Can view") + + // UnifiedRole Editor, Role Description (resolves directly) + _editorUnifiedRoleDescription = l10n.Template("View, download, upload, edit, add and delete.") + // UnifiedRole Editor, Role DisplayName (resolves directly) + _editorUnifiedRoleDisplayName = l10n.Template("Can edit") + + // UnifiedRole SpaseEditor, Role Description (resolves directly) + _spaceEditorUnifiedRoleDescription = l10n.Template("View, download, upload, edit, add and delete.") + // UnifiedRole SpaseEditor, Role DisplayName (resolves directly) + _spaceEditorUnifiedRoleDisplayName = l10n.Template("Can edit") + + // UnifiedRole FileEditor, Role Description (resolves directly) + _fileEditorUnifiedRoleDescription = l10n.Template("View, download and edit.") + // UnifiedRole FileEditor, Role DisplayName (resolves directly) + _fileEditorUnifiedRoleDisplayName = l10n.Template("Can edit") + + // UnifiedRole EditorLite, Role Description (resolves directly) + _editorLiteUnifiedRoleDescription = l10n.Template("View, download and upload.") + // UnifiedRole EditorLite, Role DisplayName (resolves directly) + _editorLiteUnifiedRoleDisplayName = l10n.Template("Can upload") + + // UnifiedRole Manager, Role Description (resolves directly) + _managerUnifiedRoleDescription = l10n.Template("View, download, upload, edit, add, delete and manage members.") + // UnifiedRole Manager, Role DisplayName (resolves directly) + _managerUnifiedRoleDisplayName = l10n.Template("Can manage") + + // UnifiedRole SecureViewer, Role Description (resolves directly) + _secureViewerUnifiedRoleDescription = l10n.Template("View only documents, images and PDFs. Watermarks will be applied.") + // UnifiedRole SecureViewer, Role DisplayName (resolves directly) + _secureViewerUnifiedRoleDisplayName = l10n.Template("Can view (secure)") +) + // NewViewerUnifiedRole creates a viewer role. func NewViewerUnifiedRole() *libregraph.UnifiedRoleDefinition { r := conversions.NewViewerRole() return &libregraph.UnifiedRoleDefinition{ Id: proto.String(UnifiedRoleViewerID), - Description: proto.String("View and download."), + Description: proto.String(_viewerUnifiedRoleDescription), DisplayName: displayName(r), RolePermissions: []libregraph.UnifiedRolePermission{ { @@ -97,7 +140,7 @@ func NewSpaceViewerUnifiedRole() *libregraph.UnifiedRoleDefinition { r := conversions.NewSpaceViewerRole() return &libregraph.UnifiedRoleDefinition{ Id: proto.String(UnifiedRoleSpaceViewerID), - Description: proto.String("View and download."), + Description: proto.String(_spaceViewerUnifiedRoleDescription), DisplayName: displayName(r), RolePermissions: []libregraph.UnifiedRolePermission{ { @@ -114,7 +157,7 @@ func NewEditorUnifiedRole() *libregraph.UnifiedRoleDefinition { r := conversions.NewEditorRole() return &libregraph.UnifiedRoleDefinition{ Id: proto.String(UnifiedRoleEditorID), - Description: proto.String("View, download, upload, edit, add and delete."), + Description: proto.String(_editorUnifiedRoleDescription), DisplayName: displayName(r), RolePermissions: []libregraph.UnifiedRolePermission{ { @@ -131,7 +174,7 @@ func NewSpaceEditorUnifiedRole() *libregraph.UnifiedRoleDefinition { r := conversions.NewSpaceEditorRole() return &libregraph.UnifiedRoleDefinition{ Id: proto.String(UnifiedRoleSpaceEditorID), - Description: proto.String("View, download, upload, edit, add and delete."), + Description: proto.String(_spaceEditorUnifiedRoleDescription), DisplayName: displayName(r), RolePermissions: []libregraph.UnifiedRolePermission{ { @@ -148,7 +191,7 @@ func NewFileEditorUnifiedRole() *libregraph.UnifiedRoleDefinition { r := conversions.NewFileEditorRole() return &libregraph.UnifiedRoleDefinition{ Id: proto.String(UnifiedRoleFileEditorID), - Description: proto.String("View, download and edit."), + Description: proto.String(_fileEditorUnifiedRoleDescription), DisplayName: displayName(r), RolePermissions: []libregraph.UnifiedRolePermission{ { @@ -165,7 +208,7 @@ func NewEditorLiteUnifiedRole() *libregraph.UnifiedRoleDefinition { r := conversions.NewEditorLiteRole() return &libregraph.UnifiedRoleDefinition{ Id: proto.String(UnifiedRoleEditorLiteID), - Description: proto.String("View, download and upload."), + Description: proto.String(_editorLiteUnifiedRoleDescription), DisplayName: displayName(r), RolePermissions: []libregraph.UnifiedRolePermission{ { @@ -182,7 +225,7 @@ func NewManagerUnifiedRole() *libregraph.UnifiedRoleDefinition { r := conversions.NewManagerRole() return &libregraph.UnifiedRoleDefinition{ Id: proto.String(UnifiedRoleManagerID), - Description: proto.String("View, download, upload, edit, add, delete and manage members."), + Description: proto.String(_managerUnifiedRoleDescription), DisplayName: displayName(r), RolePermissions: []libregraph.UnifiedRolePermission{ { @@ -199,7 +242,7 @@ func NewSecureViewerUnifiedRole() *libregraph.UnifiedRoleDefinition { r := conversions.NewSecureViewerRole() return &libregraph.UnifiedRoleDefinition{ Id: proto.String(UnifiedRoleSecureViewerID), - Description: proto.String("View only documents, images and PDFs. Watermarks will be applied."), + Description: proto.String(_secureViewerUnifiedRoleDescription), DisplayName: displayName(r), RolePermissions: []libregraph.UnifiedRolePermission{ { @@ -482,27 +525,24 @@ func displayName(role *conversions.Role) *string { return nil } - // linter wants this to be a var - canEdit := "Can edit" - var displayName string switch role.Name { case conversions.RoleViewer: - displayName = "Can view" + displayName = _viewerUnifiedRoleDisplayName case conversions.RoleSpaceViewer: - displayName = "Can view" + displayName = _spaceViewerUnifiedRoleDisplayName case conversions.RoleEditor: - displayName = canEdit + displayName = _editorUnifiedRoleDisplayName case conversions.RoleSpaceEditor: - displayName = canEdit + displayName = _spaceEditorUnifiedRoleDisplayName case conversions.RoleFileEditor: - displayName = canEdit + displayName = _fileEditorUnifiedRoleDisplayName case conversions.RoleEditorLite: - displayName = "Can upload" + displayName = _editorLiteUnifiedRoleDisplayName case conversions.RoleManager: - displayName = "Can manage" + displayName = _managerUnifiedRoleDisplayName case conversions.RoleSecureViewer: - displayName = "Can view (secure)" + displayName = _secureViewerUnifiedRoleDisplayName default: return nil }