Pushkal-Gupta opened a new pull request, #77474:
URL: https://github.com/apache/airflow/pull/77474
The Security menu names each of its links with the English text the API
sent, while showing the translated word. An `aria-label` overrides the
element's visible text when the browser works out an accessible name, so on a
translated UI the two disagree:
```tsx
<Link aria-label={text} to={path}> // "Users", straight from the API
{translate(`security.${securityKey}`)} // "Benutzer" on a German UI
</Link>
```
A screen reader reads out "Users" on a menu item that says "Benutzer". Voice
control is worse off still, because the visible word is not the name the
control answers to.
This is live on a stock FAB install in all 20 non-English locales. Every one
of them translates all five keys, so the mismatch happens for every item in the
menu:
| Locale | Shown | Announced |
| --- | --- | --- |
| de | Benutzer | Users |
| ja | ユーザ | Users |
| pt | Usuários | Users |
The two sibling menus next door do it the other way round. `BrowseButton`
resolves its label once and passes the same value to both, and `AdminButton`
calls `translate(...)` in both places. `SecurityButton` is the only one of the
three that names a link from something other than what it displays, which reads
like a slip rather than a decision.
## The second half: an item with no key renders the key
`securityKey` is derived from the API's text, and only the five items FAB
sends have a translation. `get_extra_menu_items` is a documented extension
point on `BaseAuthManager`, so a custom auth manager can return anything, and
an item outside those five had nothing to fall back on. The menu showed
`security.audit-logs` where it meant "Audit Logs".
The house style for a key built at runtime is already a `defaultValue` here.
`WarningAlert`, `Callbacks` and `translateCompletionRule` all pass one, each
with a comment saying why. This adds the same thing, falling back to the auth
manager's own text.
## What this changes
The label is resolved once, with a `defaultValue`, and used for both the
visible text and the accessible name.
Not changed: `key` and `value` on the menu item stay the API's English text,
since they are the item's identity rather than its wording and should not move
when the language does.
## Verification
Reverting the component fails both new tests. The first cannot find a menu
item named "Benutzer"; the second finds `security.audit-logs` rendered on
screen, which is the bug in one line of output.
Registering the bundle in the test is deliberate. `Wrapper` fetches the
locale files over HTTP and jsdom does not serve them, so without it `translate`
hands back the key and there is no translated wording to assert against. The
label used in the test is one the component could not produce by accident.
`oxfmt --check`, `oxlint`, `eslint --quiet` and `tsc` all pass. The Nav
suite, the Security page test and the i18n guards pass together: 16 files, 150
tests. The prek hooks that apply to both files pass.
No newsfragment: this is an ordinary bug fix.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes - Claude Code (Opus 5)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]