optimize generated l10n scripts (JS) by excluding strings we don't have translations for

VERIFIED FIXED in 2015-08-11

Status

Marketplace
Code Quality
P4
enhancement
VERIFIED FIXED
3 years ago
3 years ago

People

(Reporter: ngoke, Assigned: ngoke)

Tracking

({perf})

2015-08-11
x86
Mac OS X
Points:
---

Details

(Assignee)

Description

3 years ago
We can reduce the size of locale scripts by excluding strings that we don't have translations for. It's a waste to have something over and over like:

window.navigator.l10n.strings= {"Some message": {"body": "Some message"}}

Solving this would drastically empty the en-US.js locale script at https://marketplace.cdn.mozilla.net/media/fireplace/locales/en-US.js and decrease the size of every locale script file.

We have to modify our .po locale file parser and generator to exclude those strings. Then we modify our l10n module's gettext to just return the original English string if a translation wasn't found.

We could further decrease the size by flattening the overall data structure to not have so many nested objects. For non-plurals, we may be able to do a straight-up map "Some message": "Some message". 

We could also rename the keys to be shorter. "body" -> "b". More obfuscated, but as the hackneyed saying goes, "every byte counts".
(Assignee)

Updated

3 years ago
Blocks: 1075278
Keywords: perf

Updated

3 years ago
Severity: normal → enhancement
Priority: -- → P4
Emptying out English and shortening names, sure.  We shouldn't spend time doing the same in all the other locales though.  The right answer there is either to finish localizing or drop the localization.
(Assignee)

Comment 2

3 years ago
This would only apply for the *generated* locale files consumed by JS. It won't affect the .po files themselves.
(Assignee)

Updated

3 years ago
Assignee: nobody → kngo
(Assignee)

Comment 3

3 years ago
Node piece: https://github.com/mozilla/commonplace/pull/64/

1. Optimizes {'myString': {'body': 'elString'}} => {'myString': 'elString'}

2. Optimizes {'myString': {'body': '', 'plural': 'myStrings', 'plurals': ['elString', 'elStrings']}} => {'myString': ['elString', 'elStrings']}

3. Drops occurrences of {'myString: {'body': 'myString'}}

4. Drops occurrences of {'myString': {'body': ''}}

Our custom frontend l10n module will need to be patched to expect this.
(Assignee)

Comment 5

3 years ago
STR:

Just check l10n is still working on Marketplace.
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 2015-08-11

Comment 6

3 years ago
Verified as fixed in various pages and languages
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.