Skip to content

fix: register the app menu entry in PHP so "Office" isn't translated - #200

Open
juliusknorr with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-translated-app-name
Open

juliusknorr with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-translated-app-name

Conversation

Copilot AI commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

The navigation name in info.xml is extracted to Transifex, so the product name "Office" got translated (e.g. "Büro"). The <navigations> block is removed and the entry is now registered via INavigationManager in a new LoadNavigationEntryListener on LoadAdditionalEntriesEvent (same approach as spreed), with an untranslated name and the same route, icon and type.

Notes:

  • The entry and the per-category app menu actions are only added for users the app is enabled for, so "Limit to groups" keeps working (the info.xml entry was filtered by the server, the listener is not).
  • order => 10 is new, the old entry had none.
  • Stale "Office" translations can only be cleaned up in Transifex, since the top-level <name> is still extracted.

Fixes #17

Copilot AI linked an issue Oct 14, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix app name translation to retain product name fix: register the app menu entry in PHP so "Office" isn't translated Oct 14, 2026
Copilot AI requested a review from juliusknorr October 14, 2026 18:18
@juliusknorr
juliusknorr marked this pull request as ready for review October 14, 2026 18:21
…ated

Assisted-by: GitHubCopilot:copilot-swe-agent
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Julius Knorr <jus@bitgrid.net>
@juliusknorr
juliusknorr force-pushed the copilot/fix-translated-app-name branch from 17aaabb to 9ccce57 Compare October 15, 2026 06:37
@juliusknorr
juliusknorr requested a review from elzody October 15, 2026 09:39
@juliusknorr
juliusknorr requested a review from moodyjmz November 6, 2026 08:56
@juliusknorr juliusknorr added the enhancement New feature request label Nov 6, 2026
@moodyjmz

moodyjmz commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

The entry is no longer gated per user: with Office limited to groups, users outside them get an "Office" tile that leads to "Page not found". The info.xml entry was only built for apps in getEnabledAppsForUser(); the listener is registered for every enabled app and adds unconditionally. A closure with an isEnabledForUser() check, plus an explicit 'app' key, fixes it, and is what INavigationManager::add asks for.

Detail

Cause

Repro

Server 36.0.0 dev (continuous-integration-shallow-server:latest), occ app:enable office --groups finance, alice in finance, bob not. Entries from GET /ocs/v2.php/core/navigation/apps:

alice bob
main dashboard, files, office dashboard, files
this PR dashboard, files, office dashboard, files, office (app: null)

On this PR, bob clicking the tile gets "Page not found". With defaultapp = office,dashboard,files, bob lands on /apps/office/ ("Page not found") after login; on main he lands on the Dashboard.

menu-base-bob-header menu-pr-bob-header menu-pr-bob-office-click

Knock-on effects (same cause)

  • Default app (reproduced above): getDefaultEntryIdForUser() / getDefaultEntryIds() treat any id in the entries as available (NavigationManager.php#L461-L480). With office in defaultapp, users outside the group are sent to /apps/office/ after login.
  • Missing 'app' key (reproduced above): for those users processEntry() doesn't fill it in, and AppManager::getDefaultAppForUser(), getDefaultApps() and setDefaultApps() read $entry['app'] unguarded (AppManager.php#L1040-L1065). The add() docblock says link entries shall set app and that a closure is preferred (INavigationManager.php#L83-L84).

Suggested fix

public function __construct(
	private IAppManager $appManager,
	private INavigationManager $navigationManager,
	private IURLGenerator $urlGenerator,
) {
}

#[\Override]
public function handle(Event $event): void {
	if (!$event instanceof LoadAdditionalEntriesEvent) {
		return;
	}

	$this->navigationManager->add(function (): ?array {
		if (!$this->appManager->isEnabledForUser(Application::APP_ID)) {
			return null;
		}

		return [
			'id' => Application::APP_ID,
			'app' => Application::APP_ID,
			'type' => INavigationManager::TYPE_APPS,
			'href' => $this->urlGenerator->linkToRoute(Application::APP_ID . '.page.index'),
			'icon' => $this->urlGenerator->imagePath(Application::APP_ID, 'app.svg'),
			'name' => 'Office',
		];
	});
}

Plus a test case for a user the app isn't enabled for (closure returns null). The current mocks return fixed strings for any linkToRoute() / imagePath() argument (LoadNavigationEntryListenerTest.php#L24-L25), so a wrong route or icon name would also pass.

Non-blocking

  • 'order' => 10: users without a saved app order get DEFAULT_APP_ORDER['office'] (-98) regardless. It only changes placement for users with a saved order that lacks office, which is the case the server comment at NavigationManager.php#L132-L134 avoids. Dropping it keeps the old fallback of 100 (NavigationManager.php#L136).
  • PHPUnit doesn't run in CI here: test-unit.yml only runs npm run test:unit, so the green test-unit check doesn't cover the new PHP test (or the existing AppMenuActionListenerTest).
  • AppMenuActionListener has the same gap for its per-category actions (it only checks isLoggedIn()); the same isEnabledForUser() check would cover both.

@juliusknorr

Copy link
Copy Markdown
Member

Oh good catch. Could argue that this should be server responsibility, but let me add a quick check in here

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Julius Knorr <jus@bitgrid.net>
…ed for

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Julius Knorr <jus@bitgrid.net>
@juliusknorr

Copy link
Copy Markdown
Member

Thanks, added the isEnabledForUser() check for the nav entry (closure plus app key) and the app menu actions, with tests for users outside the group. Kept order, happy to drop it if you prefer. PHPUnit in CI as a follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App name is translated

3 participants