payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
24.59k stars 1.56k forks source link

Label function for document view tab does not apply selected language translation correctly #8410

Open amun1620 opened 3 weeks ago

amun1620 commented 3 weeks ago

Link to reproduction

No response

Environment Info

Payload: 3.0.0-beta.108
Node: 20.17.0
Next.js: 15.0.0-canary.160

Describe the Bug

When using a label function on a document view tab that returns a translated string using the provided t function, the user's selected language is not applied. A field with the same label function translates the label appropriately into the correct language.

It seems to choose the language to translate the string into arbitrarily, and toggling the user's language preference has no effect on what the label translation resolves to.

For example, with Spanish selected:

image

With English selected, the tab text is still in Spanish.

image

Reproduction Steps

Collection's Document View Config:

  admin: {
    components: {
      views: {
        edit: {
          customView: {
            Component: "/src/components/enrollments-view#EnrollmentsView",
            path: "/enrollments",
            tab: {
              label: ({ t }) => t("enrollments:label"),
              href: "/enrollments",
            },
          },
        },
      },
    },
  },

Example Field Config:

  fields: [
    {
      name: "tester",
      type: "text",
              label: ({ t }) => t("enrollments:label"),
    },
  ]

Adapters and Plugins

No response

paulpopus commented 3 weeks ago

Fixing in https://github.com/payloadcms/payload/pull/8422

github-actions[bot] commented 3 weeks ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

paulpopus commented 3 weeks ago

Reopening to keep track of this one, the fix will be merged later on after another big PR