/******************************************************************************

 Author: Esmit Pérez C.
 Date:   May 18, 2003
 Build:  1

 Description:
 Adds i18n support to qForms

 GNU License
 ---------------------------------------------------------------------------
 This library provides common methods for interacting with HTML forms
 Copyright (C) 2001  Dan G. Switzer, II

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for mser details.
 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
******************************************************************************/ 
 

function I18n(language){
	this.language = language || "en";
}

// Let's use english by default
function _I18n_setLanguage(lang){	
	this.language = lang || "en";
}

function _I18n_getLanguage(){
	return this.language;
}


// We pass any additional params to complete the i18n string
function _I18n_getString(strToGet){
	var res = strToGet+" NOT FOUND";
	res = Language[this.language][strToGet];
	
	// In case we passed in more parameters
	var optionalArguments = arguments.length - 1		
	for (i=1;i<=optionalArguments;i++){					
		res = res.replace("{"+i+"}",arguments[i])
	}			
	return res;
}

I18n.prototype.setLanguage = _I18n_setLanguage;
I18n.prototype.getLanguage = _I18n_getLanguage;
I18n.prototype.getString = _I18n_getString;