diff --git a/changelog/unreleased/lang-supp-in-app.md b/changelog/unreleased/lang-supp-in-app.md
new file mode 100644
index 0000000000..b55e6372ea
--- /dev/null
+++ b/changelog/unreleased/lang-supp-in-app.md
@@ -0,0 +1,10 @@
+Enhancement: added support for configuring language locales in apps
+
+This is a partial backport from edge: we introduce a language option
+in the appprovider, which if set is passed as appropriate parameter
+to the external apps in order to force a given localization. In particular,
+for Microsoft Office 365 the DC_LLCC option is set as well.
+The default behavior is unset, where apps try and resolve the
+localization from the browser headers.
+
+https://github.com/cs3org/reva/pull/3303
diff --git a/examples/storage-references/gateway.toml b/examples/storage-references/gateway.toml
index 0031856e2c..963d0fe21d 100644
--- a/examples/storage-references/gateway.toml
+++ b/examples/storage-references/gateway.toml
@@ -46,6 +46,7 @@ mime_types = [
[grpc.services.appprovider]
mime_types = ["text/plain"]
+language = "en-GB"
[http.services.datagateway]
[http.services.prometheus]
diff --git a/internal/grpc/services/appprovider/appprovider.go b/internal/grpc/services/appprovider/appprovider.go
index eea33b20c1..881dc4c4b7 100644
--- a/internal/grpc/services/appprovider/appprovider.go
+++ b/internal/grpc/services/appprovider/appprovider.go
@@ -58,6 +58,7 @@ type config struct {
GatewaySvc string `mapstructure:"gatewaysvc"`
MimeTypes []string `mapstructure:"mime_types"`
Priority uint64 `mapstructure:"priority"`
+ Language string `mapstructure:"language"`
}
func (c *config) init() {
@@ -170,7 +171,7 @@ func getProvider(c *config) (app.Provider, error) {
}
func (s *service) OpenInApp(ctx context.Context, req *providerpb.OpenInAppRequest) (*providerpb.OpenInAppResponse, error) {
- appURL, err := s.provider.GetAppURL(ctx, req.ResourceInfo, req.ViewMode, req.AccessToken)
+ appURL, err := s.provider.GetAppURL(ctx, req.ResourceInfo, req.ViewMode, req.AccessToken, s.conf.Language)
if err != nil {
res := &providerpb.OpenInAppResponse{
Status: status.NewInternal(ctx, errors.New("appprovider: error calling GetAppURL"), err.Error()),
diff --git a/pkg/app/app.go b/pkg/app/app.go
index a6edad2a02..50e6ce28d8 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -40,6 +40,6 @@ type Registry interface {
// Provider is the interface that application providers implement
// for interacting with external apps that serve the requested resource.
type Provider interface {
- GetAppURL(ctx context.Context, resource *provider.ResourceInfo, viewMode appprovider.OpenInAppRequest_ViewMode, token string) (*appprovider.OpenInAppURL, error)
+ GetAppURL(ctx context.Context, resource *provider.ResourceInfo, viewMode appprovider.OpenInAppRequest_ViewMode, token, language string) (*appprovider.OpenInAppURL, error)
GetAppProviderInfo(ctx context.Context) (*registry.ProviderInfo, error)
}
diff --git a/pkg/app/provider/demo/demo.go b/pkg/app/provider/demo/demo.go
index 896893fa65..9376251aa1 100644
--- a/pkg/app/provider/demo/demo.go
+++ b/pkg/app/provider/demo/demo.go
@@ -38,8 +38,8 @@ type demoProvider struct {
iframeUIProvider string
}
-func (p *demoProvider) GetAppURL(ctx context.Context, resource *provider.ResourceInfo, viewMode appprovider.OpenInAppRequest_ViewMode, token string) (*appprovider.OpenInAppURL, error) {
- url := fmt.Sprintf("", p.iframeUIProvider, resource.Id.StorageId+":"+resource.Id.OpaqueId, viewMode.String(), token)
+func (p *demoProvider) GetAppURL(ctx context.Context, resource *provider.ResourceInfo, viewMode appprovider.OpenInAppRequest_ViewMode, token, language string) (*appprovider.OpenInAppURL, error) {
+ url := fmt.Sprintf("", p.iframeUIProvider, resource.Id.StorageId+":"+resource.Id.OpaqueId, viewMode.String(), token, language)
return &appprovider.OpenInAppURL{
AppUrl: url,
Method: "GET",
diff --git a/pkg/app/provider/wopi/wopi.go b/pkg/app/provider/wopi/wopi.go
index bec75f63a3..40dd91cb7a 100644
--- a/pkg/app/provider/wopi/wopi.go
+++ b/pkg/app/provider/wopi/wopi.go
@@ -125,7 +125,7 @@ func New(m map[string]interface{}) (app.Provider, error) {
}, nil
}
-func (p *wopiProvider) GetAppURL(ctx context.Context, resource *provider.ResourceInfo, viewMode appprovider.OpenInAppRequest_ViewMode, token string) (*appprovider.OpenInAppURL, error) {
+func (p *wopiProvider) GetAppURL(ctx context.Context, resource *provider.ResourceInfo, viewMode appprovider.OpenInAppRequest_ViewMode, token, language string) (*appprovider.OpenInAppURL, error) {
log := appctx.GetLogger(ctx)
ext := path.Ext(resource.Path)
@@ -238,6 +238,19 @@ func (p *wopiProvider) GetAppURL(ctx context.Context, resource *provider.Resourc
appFullURL := result["app-url"].(string)
+ if language != "" {
+ url, err := url.Parse(appFullURL)
+ if err != nil {
+ return nil, err
+ }
+ urlQuery := url.Query()
+ urlQuery.Set("ui", language) // OnlyOffice + Office365
+ urlQuery.Set("lang", language) // Collabora
+ urlQuery.Set("rs", language) // Office365, https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/online/discovery#dc_llcc
+ url.RawQuery = urlQuery.Encode()
+ appFullURL = url.String()
+ }
+
// Depending on whether wopi server returned any form parameters or not,
// we decide whether the request method is POST or GET
var formParams map[string]string
diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go
index 14ec95e4fa..54033e3386 100644
--- a/pkg/utils/utils.go
+++ b/pkg/utils/utils.go
@@ -348,6 +348,8 @@ func GetViewMode(viewMode string) gateway.OpenInAppRequest_ViewMode {
return gateway.OpenInAppRequest_VIEW_MODE_READ_ONLY
case "write":
return gateway.OpenInAppRequest_VIEW_MODE_READ_WRITE
+ case "preview":
+ return gateway.OpenInAppRequest_VIEW_MODE_PREVIEW
default:
return gateway.OpenInAppRequest_VIEW_MODE_INVALID
}