fix(core): resolve topbar/prefs app names with dgettext against ownin…#189
Conversation
…g app's domain _() in Topbar::getTree() and _sortByName() translates against the ambient default gettext domain, not the domain of the app owning the name. Non-current apps intermittently fall back to raw English msgids. Use dgettext($app, ...) instead, resolved before sorting in the prefs submenu since uasort()'s comparator has no access to the app key.
…lder dgettext() only resolves against a domain that was bound this request, but Horde binds an app's domain only when the app is pushed. Apps that merely appear in the topbar/prefs menu (never pushed) therefore still fell back to the raw English name. Bind the owning app's domain (bindtextdomain + bind_textdomain_codeset) before dgettext(); dgettext() leaves the active default domain untouched, so no save/restore is needed. Resolve names where they originate, so headings and links -- which have no dedicated app domain -- keep the ambient _() behaviour instead of being forced through a per-app domain that would leave them untranslated. Apply the same fix to the modern src/Topbar/TopbarBuilder.php, which had the identical _() bug and is used by the desktop chrome renderer. Add TopbarBuilder regression tests: a deterministic guard that app names trigger per-app domain resolution while headings do not, plus a behavioural test proving translation via the owning domain.
|
I pushed a follow-up commit to this branch ( 1.
|
|
@jcdelepine , thanks for contributing. I saw some gaps, and filled it. still i'm not the expert here, we need a review from @ralflang whether the general direction is right. |
|
TBH I cannot reproduce this - my topbar has translated names for all apps, currently active or otherwise. Switching from base to kronolith to turba doesn't change this. Before accepting I'd like to understand how your environment is different. |
|
I understand the topbar itself never correctly did this but a side effect coupling the topbar to other stuff registry does in the pushapp/popapp cycle masked the problem. |
Problem
Horde_Core_Topbarrenders app names via plain_(), which uses thecurrently active default gettext domain rather than the domain owning
the string. Since
$params['name']holds each app's raw msgid(left untranslated at registry-parse time), non-current apps in the
menu silently fall back to the raw English name whenever the active
domain doesn't match.
Symptom
Topbar/prefs menu shows English app names ("Mail", "Calendar", "Task")
instead of localized ones, depending on which app is current. Confirmed
on two identical checkouts (same commit, same
.mofiles), each with adifferent pattern — consistent with the active domain depending on
request execution order, not persisted state.
Fix
Use
dgettext($app, $params['name']), resolved explicitly per appinstead of relying on the ambient default domain. For the prefs
submenu, translation happens in a pass over
$prefs_appsbeforeuasort(), since the comparator only sees values, not app keys;_sortByName()now just doesstrcoll()on already-resolved names.Already-translated entries (Administration, Preferences, Help, etc.)
are unaffected — verified, not assumed.
Testing
Reproduced reliably on two independent installs from the same commit;
fix verified correct for kronolith/turba/imp/nag/mnemo in both the
topbar and preferences menu regardless of current app.