Closed Bug 1144425 Opened 10 years ago Closed 9 years ago

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

Categories

(Marketplace Graveyard :: Code Quality, enhancement, P4)

x86
macOS
enhancement

Tracking

(Not tracked)

VERIFIED FIXED
2015-08-11

People

(Reporter: kngo, Assigned: kngo)

References

Details

(Keywords: perf)

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".
Keywords: perf
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.
This would only apply for the *generated* locale files consumed by JS. It won't affect the .po files themselves.
Assignee: nobody → kngo
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.
STR: Just check l10n is still working on Marketplace.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → 2015-08-11
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.