Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | 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
 
11
dojo.provide("dojo.i18n.common");
12
dojo.i18n.getLocalization = function (packageName, bundleName, locale) {
13
	dojo.hostenv.preloadLocalizations();
14
	locale = dojo.hostenv.normalizeLocale(locale);
15
	var elements = locale.split("-");
16
	var module = [packageName, "nls", bundleName].join(".");
17
	var bundle = dojo.hostenv.findModule(module, true);
18
	var localization;
19
	for (var i = elements.length; i > 0; i--) {
20
		var loc = elements.slice(0, i).join("_");
21
		if (bundle[loc]) {
22
			localization = bundle[loc];
23
			break;
24
		}
25
	}
26
	if (!localization) {
27
		localization = bundle.ROOT;
28
	}
29
	if (localization) {
30
		var clazz = function () {
31
		};
32
		clazz.prototype = localization;
33
		return new clazz();
34
	}
35
	dojo.raise("Bundle not found: " + bundleName + " in " + packageName + " , locale=" + locale);
36
};
37
dojo.i18n.isLTR = function (locale) {
38
	var lang = dojo.hostenv.normalizeLocale(locale).split("-")[0];
39
	var RTL = {ar:true, fa:true, he:true, ur:true, yi:true};
40
	return !RTL[lang];
41
};
42