fix(pwa): load translations from the endpoint frappe v17 exposes - #5148
Open
phet2 wants to merge 1 commit into
Open
fix(pwa): load translations from the endpoint frappe v17 exposes#5148phet2 wants to merge 1 commit into
phet2 wants to merge 1 commit into
Conversation
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.
Contributor
Confidence Score: 5/5The 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The PWA fetches
frappe.translate.load_all_translations, which no longer exists in frappe v17:The request throws, the
catchintranslationsPlugin.jsswallows it, andmessagesstays{}— so the PWA renders untranslated English regardless of what the user or the site is set to. The desk at/deskis translated;/hrmsis not.To reproduce
/hrms.Failed to fetch translations:.Fix
v17 exposes
frappe.translate.get_boot_translationsinstead. Two follow-on details:message— unwrapped here.boot.translations_version, the key the server actually sends.boot.translations_hashwas alwaysundefined, so it silently fell through toMath.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:
After: