Saturday, July 3, 2010

Qooxdoo: Splitting I18N Into Parts

Normally qooxdoo is used as a Widget Toolkit resp. as a framework to build Rich Internet Applications which indicates having a lot of text to be distributed with your - yet too big - JavaScript code. The more languages you support the more text and kilobytes are added to your application code.

Because most of the clients are satisfied by using an application in that one language they halfway understand there is no need to send all that other non-sense to them as well.

Part Loading: Split the I18N load

You might know qooxdoos part loading mechanism yet. This mechanism can be used to split I18N into parts/packages that can be loaded dedicated at runtime. Therefore use the following configuration in your config.json. The important thing is - as you might have expected - the "i18n-with-boot" key.

Specify the languages you support withing the let key LOCALES which takes an array. For every locale a package named ${APPLICATION}-${locale}.js will be created into your build directory.

Load the language package you need with qx.io.PartLoader.require(["en"]).

Completely Remove I18N Information In Low-Level Applications

There might be cases where you use qx as a low-level framework for e.g. DOM manipulation, as Ajax Layer or whatever. In that cases where you do not use any LocalizedString or any qooxdoo widget that needs LocalizedStrings (e.g. the DateField) you can use the above mechanism to save some kBs.

That is because the qooxdoo generator ALWAYS includes the LocalizedStrings for all qooxdoo widgets even if you dont use a single widget and/or your application is via definition a BOM application. To get rid of that unnecessary stuff we "defer" the I18N loading into a package that we will simply never load. That will save about 10kB unzipped.

Add "let" : { "LOCALES" : [] } to your config.json so that only the default language package (${APPLICATION}-C.js) will be created.

Thanks for following.

freak

No comments:

Post a Comment

Please leave your comment here.