Subversion Repositories Applications.papyrus

Rev

Rev 1987 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.i18n.common");
14
dojo.i18n.getLocalization = function (packageName, bundleName, locale) {
15
	dojo.hostenv.preloadLocalizations();
16
	locale = dojo.hostenv.normalizeLocale(locale);
17
	var elements = locale.split("-");
18
	var module = [packageName, "nls", bundleName].join(".");
19
	var bundle = dojo.hostenv.findModule(module, true);
20
	var localization;
21
	for (var i = elements.length; i > 0; i--) {
22
		var loc = elements.slice(0, i).join("_");
23
		if (bundle[loc]) {
24
			localization = bundle[loc];
25
			break;
26
		}
27
	}
28
	if (!localization) {
29
		localization = bundle.ROOT;
30
	}
31
	if (localization) {
32
		var clazz = function () {
33
		};
34
		clazz.prototype = localization;
35
		return new clazz();
36
	}
37
	dojo.raise("Bundle not found: " + bundleName + " in " + packageName + " , locale=" + locale);
38
};
39
dojo.i18n.isLTR = function (locale) {
40
	var lang = dojo.hostenv.normalizeLocale(locale).split("-")[0];
41
	var RTL = {ar:true, fa:true, he:true, ur:true, yi:true};
42
	return !RTL[lang];
43
};
44