class Lang {
	private langTypes = {
		zh: LANG_CN,
		en: LANG_EN
	};
	langEnum: string = 'zh';//['zh', 'en', 'kr'];
	lang(): LangConfig {
		return this.langTypes[this.langEnum];
	}

	private static _instance: Lang;

	static get instance(): Lang {
		if (!this._instance) {
			this._instance = new Lang();
		}
		return this._instance;
	}

	private eventDispatcher: egret.EventDispatcher;


	register(): void {
		window.addEventListener("message", this.langChange.bind(this), false);
	}

	private langChange(ev: MessageEvent): void {
		if (ev.data.lang) {
			this.langEnum = ev.data.lang;
			this.dispatchEvent(new egret.Event(SocketEvent.LANG_CHANGE, false, false))
		}
	}

	public constructor() {
		this.langEnum = Cookie.getCookie('eosget_lang') || Util.getLanguage();
		this.eventDispatcher = new egret.EventDispatcher();
	}

	public dispatchEvent(event: egret.Event) {
		this.eventDispatcher.dispatchEvent(event);
	}

	/**
	 * 添加事件监听
	 */
	addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any {
		this.eventDispatcher.addEventListener(type, listener, thisObject, useCapture, priority);
	}

	/**
	 * 移除事件监听
	 */
	removeEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean): void {
		this.eventDispatcher.removeEventListener(type, listener, thisObject, useCapture);
	}
}