forked from KRDS/kite.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.js
44 lines (36 loc) · 809 Bytes
/
core.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
define('kite/core', function()
{
var Core =
{
version : '0.9',
isInit : false,
hasCustomLocale : false,
locale : null,
init: function(opts)
{
if( ! opts.locale)
return;
Core.isInit = true;
Core.locale = opts.locale;
Core.hasCustomLocale = opts.hasCustomLocale || false;
},
injectLocale: function(url, force_inject)
{
var reg_locale = /[\?&]locale=[a-z]{2}_[A-Z]{2}/;
var do_inject = Core.hasCustomLocale || force_inject;
if(do_inject && reg_locale.test(url) === false)
{
if(url.indexOf('?') === -1)
url = url + '?locale=' + Core.locale;
else
url = url + '&locale=' + Core.locale;
}
return url;
}
};
Core.init({
locale : Env.core.locale,
hasCustomLocale : Env.core.hasCustomLocale
});
return Core;
});