1 namespace("kivi", function(ns) {
4 ns.t8 = function(text, params) {
5 var text = ns._locale[text] || text;
7 if( Object.prototype.toString.call( params ) === '[object Array]' ) {
8 var len = params.length;
10 for(var i=0; i<len; ++i) {
12 var value = params[i];
13 text = text.split("#"+ key).join(value);
16 else if( typeof params == 'object' ) {
17 for(var key in params) {
18 var value = params[key];
19 text = text.split("#{"+ key +"}").join(value);
26 ns.setupLocale = function(locale) {
30 ns.reinit_widgets = function() {
31 $('.datepicker').each(function() {
36 $('input.part_autocomplete').each(function(idx, elt){
37 kivi.PartPicker($(elt));
41 // Return a function object by its name (a string). Works both with
42 // global functions (e.g. "check_right_date_format") and those in
43 // namespaces (e.g. "kivi.t8").
44 // Returns null if the object is not found.
45 ns.get_function_by_name = function(name) {
46 var parts = name.match("(.+)\\.([^\\.]+)$");
49 return namespace(parts[1])[ parts[2] ];
53 kivi = namespace('kivi');