jQuery(function($){ /** * TRANSLATOR PLUGIN * * Example: * var trans = jQuery("input[type='text'], textarea").not(":hidden").Translatable(["es", "en"]) ===> convert input/textarea into translatable panel * * trans.trigger("trans_integrate") ==> encode translations into owner element */ /** * * @param languages => ["es", "en", 'fr'] * @param default_language => not important * @returns {$.fn.Translatable} * @constructor */ var TRANSLATOR_counter = 1; $.fn.Translatable = function(languages, default_language){ default_language = default_language?default_language:languages[0]; var self = this; // decode translations // text: string containing translations // language(optional): get translation value for this language // return a hash of translations get_translations = function(text, language){ var translations_per_locale = {}; var res = ""; if(text.trim().search("'); for(var i in splitted){ var str = splitted[i]; var m_atch = str.trim().match(/^", "") } } res = translations_per_locale; } if(language) return get_translation(res, language); else return res; } // get translation for a language get_translation = function(translations, language){ return language in translations?translations[language]:(languages[0] in translations?translations[languages[0]]: ""); } //if translations is a uniq language if(languages.length < 2){ $(self).each(function(){ $(this).val(get_translations($(this).val(), languages[0])); }); return this; } $(self).each(function(){ var ele = $(this); var tabs_title = [], tabs_content = [], translations = get_translations(ele.val()), inputs = {}; // decoding languages for(var ii in languages){ var l = languages[ii]; var key = "translation-"+l+"-"+TRANSLATOR_counter; tabs_title.push('