Skip to content

fix(pwa): load translations from the endpoint frappe v17 exposes - #5148

Open
phet2 wants to merge 1 commit into
frappe:developfrom
phet2:fix/pwa-translations-endpoint
Open

fix(pwa): load translations from the endpoint frappe v17 exposes#5148
phet2 wants to merge 1 commit into
frappe:developfrom
phet2:fix/pwa-translations-endpoint

Conversation

@phet2

@phet2 phet2 commented Aug 25, 2026

Copy link
Copy Markdown

Problem

The PWA fetches frappe.translate.load_all_translations, which no longer exists in frappe v17:

{"exception":"frappe.exceptions.ValidationError: ... module 'frappe.translate' has no attribute 'load_all_translations'"}

The request throws, the catch in translationsPlugin.js swallows it, and messages stays {} — so the PWA renders untranslated English regardless of what the user or the site is set to. The desk at /desk is translated; /hrms is not.

To reproduce

  1. Set a site and a user to any non-English language.
  2. Open /hrms.
  3. Everything renders in English. The console shows Failed to fetch translations:.

Fix

v17 exposes frappe.translate.get_boot_translations instead. Two follow-on details:

  • It is whitelisted, so the payload arrives under message — unwrapped here.
  • The cache-busting token now reads boot.translations_version, the key the server actually sends. boot.translations_hash was always undefined, so it silently fell through to Math.random() and defeated the HTTP cache on every load. The endpoint is decorated with @http_cache(max_age=31536000), and the payload is ~2.4 MB, so this was re-downloading it on every page load.

Verified

Against a site running in Lao: the home screen, quick links, bottom tabs and request statuses all render translated. The response is a single cached fetch instead of one per load.

Before:

Leaves · Expense Claims · Salary Slips · Check In

After:

ການລາພັກ · ການເບີກຄ່າໃຊ້ຈ່າຍ · ໃບແຈ້ງເງິນເດືອນ · ລົງເວລາເຂົ້າ

The PWA fetched frappe.translate.load_all_translations, which no longer
exists in frappe v17. The request threw, the catch swallowed it, and
`messages` stayed empty - so the app rendered untranslated English no
matter what language the user or the site was set to.

v17 exposes frappe.translate.get_boot_translations instead. It is a
whitelisted method, so its payload arrives under `message`; unwrap it.
Also read the cache-busting token from boot.translations_version, the
key the server actually sends - translations_hash was always undefined
and silently fell through to Math.random(), defeating the HTTP cache on
every load.
@greptile-apps

greptile-apps Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified.

The changed endpoint and response handling feed the existing translation map contract, while initialization occurs after boot data is available.

Reviews (1): Last reviewed commit: "fix(pwa): load translations from the end..." | Re-trigger Greptile

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant