using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TheNovel.Properties;

namespace TheNovel
{
	static class Langsup
	{
		static Dictionary<string, string> langmenu;

		public static string GetWord ( string key ) { return langmenu [ key ]; }

		static Langsup ()
		{
			LoadFile ();
		}

		public static void LoadFile ()
		{
			langmenu = new Dictionary<string, string> ();
			string lang = "";
			switch ( Settings.Default.Language )
			{ 
				case 0:
					lang = Resources.EnglishLanguagePack;
					break;
				case 1:
					lang = Resources.KoreanLanguagePack;
					break;
				case 2:
					lang = Resources.JapaneseLanguagePack;
					break;
			}

			string [] langs = lang.Split ( '\n' );
			foreach ( string i in langs )
			{
				string [] temp = i.Split ( '`' );
				langmenu.Add ( temp [ 0 ].Trim ( '\n', '\r' ), temp [ 1 ].Trim ( '\n', '\r' ) );
			}
		}

		public static void ApplyMain ( Main main )
		{
			main.MenuFile.Text = langmenu [ "filemenu" ];
			main.MenuNew.Text = main.ToolNew.Text = langmenu [ "newmenu" ];
			main.MenuOpen.Text = main.ToolOpen.Text = langmenu [ "openmenu" ];
			main.MenuSave.Text = main.ToolSave.Text = langmenu [ "savemenu" ];
			main.MenuSaveAs.Text = langmenu [ "saveasmenu" ];
			main.MenuClose.Text = langmenu [ "closemenu" ];
			main.MenuExit.Text = langmenu [ "exitmenu" ];

			main.MenuEdit.Text = langmenu [ "editmenu" ];
			main.MenuUndo.Text = main.ToolUndo.Text = langmenu [ "undomenu" ];
			main.MenuRedo.Text = main.ToolRedo.Text = langmenu [ "redomenu" ];
			main.MenuCut.Text = main.ToolCut.Text = langmenu [ "cutmenu" ];
			main.MenuCopy.Text = main.ToolCopy.Text = langmenu [ "copymenu" ];
			main.MenuPaste.Text = main.ToolPaste.Text = langmenu [ "pastemenu" ];
			main.MenuFind.Text = langmenu [ "findmenu" ];

			main.MenuChapter.Text = langmenu [ "chaptermenu" ];
			main.MenuAddChap.Text = main.ToolAddChapter.Text = langmenu [ "addmenu" ];
			main.MenuRemChap.Text = main.ToolRemoveChapter.Text = langmenu [ "remmenu" ];
			main.MenuSafetySave.Text = main.ToolSafetySave.Text = langmenu [ "safetysavemenu" ];

			main.MenuTools.Text = langmenu [ "toolsmenu" ];
			main.MenuArs.Text = langmenu [ "arsmenu" ];
			main.MenuWps.Text = langmenu [ "wpsmenu" ];
			main.MenuCcs.Text = langmenu [ "ccsmenu" ];
			main.MenuPs.Text = langmenu [ "psmenu" ];
			main.MenuOption.Text = langmenu [ "optionsmenu" ];

			main.MenuHelp.Text = langmenu [ "helpmenu" ];
			main.MenuContents.Text = main.ToolHelp.Text = langmenu [ "contentsmenu" ];
			main.MenuAbout.Text = langmenu [ "aboutmenu" ];

			main.ChapterTitles.Columns [ 0 ].Text = langmenu [ "chaptertitle" ];
		}

		public static void ApplyAddChapter ( AddChapter ac )
		{
			ac.Text = langmenu [ "addtitle" ];
			ac.label1.Text = langmenu [ "titlelabel" ];
			ac.Create.Text = langmenu [ "createbut" ];
			ac.Cancel.Text = langmenu [ "cancelbut" ];
		}

		public static void ApplyFind ( Find find )
		{
			find.Text = langmenu [ "findtitle" ];
			find.label1.Text = langmenu [ "sentencelabel" ];
			find.label2.Text = langmenu [ "replacelabel" ];
			find.groupBox1.Text = langmenu [ "findoption" ];
			find.ThisPage.Text = langmenu [ "thispage" ];
			find.AllOfChapter.Text = langmenu [ "allofchapter" ];
			find.FindWords.Text = langmenu [ "findbut" ];
			find.ReplaceWords.Text = langmenu [ "repbut" ];
			find.Cancel.Text = langmenu [ "cancelbut" ];
		}

		public static void ApplyNewFile ( NewFile nf )
		{
			nf.Text = langmenu [ "newtitle" ];
			nf.label1.Text = langmenu [ "titlelabel" ];
			nf.label2.Text = langmenu [ "writerlabel" ];
			nf.Create.Text = langmenu [ "createbut" ];
			nf.Cancel.Text = langmenu [ "cancelbut" ];
		}

		public static void ApplyOption ( Option op )
		{
			op.Text = langmenu [ "optiontitle" ];
			op.label1.Text = langmenu [ "fontlabel" ];
			op.label2.Text = langmenu [ "langlabel" ];
			op.label3.Text = langmenu [ "periodlabel" ];
			op.Save.Text = langmenu [ "savebut" ];
		}
	}
}