class Lang{

	constructor(){}

	_order = [];
	get order(){ return this._order;}
	set order(v){
		if(!Array.isArray(v)){
			console.error('Wrong data type in Lang.order()! Array expected.',v);
			return false;
		}
		this._order = v;
	}

	toString(){
		let result = '';
		for(const contentId of this.order){
			let passageContents = "";
			if(Array.isArray(contentId))
				passageContents = contentId.map(key=>this[key]).join(' ');
			else
				passageContents = this[contentId];
			if(passageContents)
				result += `<p>${passageContents}</p>`
		}
		return result;
	}

	_init(lang){
		Object.keys(lang).forEach(function (pn) {
			this[pn] = clone(lang[pn]);
		}, this);

		return this;
	}

	clone = function () {
		return (new setup.Lang())._init(this);
	};

	toJSON = function () {
		var ownData = {};
		Object.keys(this).forEach(function (pn) {
			if(typeof this[pn] !== "function")
				ownData[pn] = clone(this[pn]);
		}, this);
		return JSON.reviveWrapper('(new setup.Lang())._init($ReviveData$)', ownData);
	};
}

setup.Lang = Lang;