Tuesday, July 22, 2008

How to develop addons for rtl locales

The topic was initiated from url: http://www.babelzilla.org/content/view/316/. But the approach provided below doesn't work at all.

function getDirection() {
var myLocalBundleService = Components.classes ["@mozilla.org/intl/stringbundle;1"].getService(Components.interfaces.nsIStringBundleService);
var myLocalStrings = myLocalBundleService.createBundle("chrome://global/locale/global.dtd");
return myLocalStrings.GetStringFromName("locale.dir");
}



Good thing is that we can still read the direction property from document.dir and preference bidi.direction. The definition of bidi.direction can be found in source code:
// ------------------
964 // Text Direction
965 // ------------------
966 // 1 = directionLTRBidi *
967 // 2 = directionRTLBidi
968 pref("bidi.direction", 1);
Both of them are r/o, but here we just need to read the information.

No comments: