portainer icon indicating copy to clipboard operation
portainer copied to clipboard

/locales/en-US/translation.json ignoring prefix

Open ghnp5 opened this issue 2 years ago • 13 comments

Bug description Portainer runs inside a subdirectory: https://example.com/portainer/...

Everything works fine, except this URL, which seems to ignore the prefix ("/portainer/"): https://example.com/locales/en-US/translation.json

Expected behavior I believe it should be: https://example.com/portainer/locales/en-US/translation.json

Steps to reproduce the issue:

Open any page on Portainer

Technical details:

  • Portainer version: 2.12.0
  • Docker version (managed by Portainer): 20.10.12
  • Kubernetes version (managed by Portainer): -
  • Platform (windows/linux): CentOS 7
  • Command used to start Portainer (docker run -p 9443:9443 portainer/portainer): Using docker-compose.yml
  • Browser: Chrome 100
  • Use Case (delete as appropriate): Using Portainer at Home, Using Portainer in a Commercial setup. Business Edition < 5 nodes

ghnp5 avatar Apr 07 '22 22:04 ghnp5

Hi.

I am also noticing this bug, but I do not run in a folder. This is on the latest BE version.

request.js:60 GET https://FQDN/locales/en-US/translation.json 404 (Not Found)

prashantsomashekar avatar Apr 21 '22 23:04 prashantsomashekar

Hi. +

phederal avatar Jun 02 '22 03:06 phederal

Hi. +

In my case it was en-CA, but the same apparent issue.

wblew avatar Jun 18 '22 22:06 wblew

What I show here is that "/locales/zh-CN/translation.json" cannot be loaded. At first, I thought it was a localization configuration file, but when I looked up the file path, I found that there was only "/locales/en/translation.json". It seems that there are only some configurations in the file, and I did not find the relevant configuration on the web page

/locales/en/translation.json

{
    "reactExample":{
        "registries":{
            "link":"Registries <strong>Link</strong>",
            "useSref":"Registries useSref"
        }
    },
    "users":{
        "access-tokens":{
            "create":{
                "add-button":"Add access token",
                "description-field-label":"Description",
                "done-button":"Done",
                "form":{
                    "description-field":{
                        "error":{
                            "required":"this field is required"
                        },
                        "label":"Description"
                    }
                },
                "new-access-token":{
                    "copy-button":"Copy access token",
                    "explanation":"Please copy the new access token. You won't be able to view the token again.",
                    "title":"New access token"
                }
            }
        }
    }
}

Portainer version: 2.14.2 Docker version 20.10.17, build 100c701

Jackxwb avatar Aug 13 '22 07:08 Jackxwb

I got the same problem. Everything works expected but the network analysis tool shows two 404 errors if calling the Portainer Webpage.

In my case, i am using https://webpage.com/portainerservice/ as subdirectory for my reverse proxy.

Technical details:

  • Portainer version: 2.16.1 CE
  • Docker version: 20.10.21, build baeda1f
  • Platform: Ubuntu 20.04.5 LTS
  • Browser: Firefox Developer Edition 108.0b2 (64-Bit)
  • Reverse Proxy Setup Version: nginx/1.22.1

My Nginx Setup look like the following:

upstream portainer {
        server 127.0.0.1:6443;
}

server {
        listen 443 ssl default_server http2;
        listen [::]:443 ssl default_server http2;

        ssl_certificate /certs/crt.pem;
        ssl_certificate_key /certs/private.pem;

        server_name ...;

        add_header Strict-Transport-Security "max-age=31536000";
        add_header X-XSS-Protection "1";
        add_header X-Frame-Options "SAMEORIGIN";

        location /portainerservice/ {
                proxy_pass http://portainer/;
                proxy_http_version 1.1;
                proxy_set_header Connection "";
        }

        location /portainerservice/api/websocket/ {
                proxy_pass http://portainer/api/websocket/;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
        }
}

Like @Jackxwb mentioned, I get the same output if I try to curl the links on console:

curl http://localhost:6443/locales/de/translation.json
404 page not found

curl http://localhost:6443/locales/en/translation.json
{
  "reactExample": {
    "registries": {
      "link": "Registries <strong>Link</strong>",
      "useSref": "Registries useSref"
    }
  },
  "users": {
    "access-tokens": {
      "create": {
        "add-button": "Add access token",
        "description-field-label": "Description",
        "done-button": "Done",
        "form": {
          "description-field": {
            "error": {
              "required": "this field is required"
            },
            "label": "Description"
          }
        },
        "new-access-token": {
          "copy-button": "Copy access token",
          "explanation": "Please copy the new access token. You won't be able to view the token again.",
          "title": "New access token"
        }
      }
    }
  }
}

It tries to load /locales/en/translation.json and /locales/de/translation.json.

On the webpage, it looks like this: grafik

kevingostomski avatar Nov 17 '22 14:11 kevingostomski

Same problem for me.

URI : https://domain.local/portainer/ I use PathPrefix Traefik rule with StripPrefix middlewares. All work fine, only translation country file (fr-FR in my case) return 404 It try to GET on https://domain.local/local/... not with custom Path.

Technical details:

  • Portainer version: 2.16.1 CE
  • Docker version: 20.10.23, Swarm Mode
  • Platform: Debian 11
  • Browser: All
  • Reverse Proxy: Traefik 2.9.6 on Docker with Docker Provider

David-COUDRAY avatar Feb 07 '23 19:02 David-COUDRAY

Seems like

backend: {
   loadPath: 'locales/{{lng}}/{{ns}}.json'
}

needs to be added in the i18n.ts file to make the translations files requests relative to the base path.

See the docs of i18next-http-backend

Mastercuber avatar Mar 23 '23 16:03 Mastercuber

Same problem in Portainer CE 2.17.1

mmjc23 avatar Apr 03 '23 09:04 mmjc23

Same Portainer Community Edition 2.17.1

ferrets6 avatar Apr 14 '23 20:04 ferrets6

same

dovwatbnh avatar Jan 22 '24 18:01 dovwatbnh

I fixed this issue adding this option to init(): supportedLngs(adding array of allowed languages) so in our case add "en" to replace "en-US"

ionut avatar Apr 10 '24 08:04 ionut

Faced the same issue, solved by adding the configuration below for the proxy (I use Nginx Proxy Manager). Idea is pretty simple: it will coercively forward all those /locales requests to Portainer URL

location /locales {
    ...
    proxy_pass       http://portainer:9000;
}

spanic avatar May 07 '24 16:05 spanic