Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 454607

Summary: Improve the page load performance related to the NLS support.
Product: [ECD] Orion Reporter: libing wang <libingw>
Component: ClientAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: john.arthorne, simon_kaegi
Version: 5.0   
Target Milestone: 8.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description libing wang CLA 2014-12-09 11:45:02 EST
Currently when an Orion page is being loaded, the orion/i18n.js is called multiple times for nls support. Each call will then introduce a bootstrap call that reduces the page load performance. Then call will also be the potential cause of dead locking plugin look-up.
For instance, when the edit.html page is being loaded, the following messages bundles are required.

orion/nls/messages
orion/operations/nls/messages
orion/navigate/nls/messages
orion/search/nls/messages
orion/problems/nls/messages
orion/widgets/nls/messages
orion/settings/nls/messages
orion/crawler/nls/messages
orion/editor/nls/messages
orion/widgets/projects/nls/messages
git/nls/gitmessages
orion/edit/nls/messages

This will then introduce 12 bootstrap calls even though the browser's locale is English.

Simon and I went over this and we are trying to get rid of the orion/i18n.js during the page load.

Instead we will create sibling folders like "zh", "ja" etc, in addition to the nls/root folder. And put translation messages.js there.
We will also refactor all the logical messages.js files so that they will be consumed directly by requirejs/i18n.js.
An example of the refactoring looks like this:
BEFORE:

define(['orion/i18n!orion/compare/nls/messages', 'orion/compare/nls/root/messages'], function(bundle, root) {
	var result = {
			root:root
	};
	Object.keys(bundle).forEach(function(key) {
		if (typeof result[key] === 'undefined') { //$NON-NLS-0$
			result[key] = bundle[key];
		}
	});
	return result;
});

AFTER:

define(['orion/compare/nls/root/messages'], function(root) {
	var result = {
			root:root,
			"ja": true,
                        "zh": true
	};
	return result;
});