/**
 * Get required text from text database.
 * @param ident String- text id
 * @param args optional String or Array-arguments to replace
 * if String -> all %s are replaced with args.example var t = _text("test","Tom"); "%s and %s"->"Tom and Tom".
 * if Array -> %s are replaced with "" if there is more %s than arguments. example: var t = _text("test",["Tom","Jerry"]); "%s and %s and %s"->"Tom and Jerry and ".
 * @return string - in case of that text id is not found the empty string will be returned
 */
function _text(ident,args){
    if(!ident) return "";
    //if args is Array or Object similar to Array
    if(((args instanceof Array) || (args && typeof args == "object" && "length" in args)) && args.length >0){
        var i = 0;
        if(_text_database[ident] != undefined){ return String(_text_database[ident]).replace(/\%s/g,function(word){var res = args[i] ? args[i] : ""; i++; return res;});}
        else return "";
    }else if(typeof args == "string"){
        if(_text_database[ident] != undefined){ return String(_text_database[ident]).replace(/\%s/g,args);}
        else return "";
    }else{
        if(_text_database[ident] != undefined){ return _text_database[ident];}
        else return "";
    }
}
