package ITUannotation;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;

public class Language {
	public Language(int i) {
		LangIndex=i;
		File read = new File("Türkçe Arayüz.txt");
		if (read.exists()) {
			 BufferedReader bfr;
			try {
				bfr = new BufferedReader(new InputStreamReader
						  (new FileInputStream(read),"UTF8"));
				String tempstr ;
		
				 while(bfr.ready())
				 {
					 tempstr=bfr.readLine();
					 Türkçes.add(tempstr);
				 }
		 File read2 = new File("English Interface.txt");
			if (read2.exists()) {
				 BufferedReader bfr2;
				
					bfr2 = new BufferedReader(new InputStreamReader
							  (new FileInputStream(read2),"UTF8"));
					String tempstr2 ;
				
					 while(bfr2.ready())
					 {
						 tempstr2=bfr2.readLine();
						 English.add(tempstr2);
					
					 }
				
			}
				
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
		}
		// TODO Auto-generated constructor stub
	}
	public void setLangIndex(int langIndex) {
		LangIndex = langIndex;
		
	}
	public int getLangIndex() {
		return LangIndex;
		
	}
	public String getLan(int labnum,int langindex) {
		// TODO Auto-generated method stub
		String label="";
		String num=Integer.toString(labnum)+")";
		if(langindex==0)
		{
		for(int i=0;i<Türkçes.size();i++)
		{
			String temp=Türkçes.get(i);
			if(temp.contains(num))
			{
				int k=temp.indexOf(")");
				label=temp.substring(k+1);
				break;
			}
			
		}
		}
		if(langindex==1)
		{
			for(int i=0;i<English.size();i++)
			{
				String temp=English.get(i);
				if(temp.contains(num))
				{
					int k=temp.indexOf(")");
					label=temp.substring(k+1);
					break;
				}
			}

		}
		return label;
	}
	
	
	
	
	
	
	private int LangIndex;
	private ArrayList<String>  Türkçes= new ArrayList<String>();
	private ArrayList<String>  English= new ArrayList<String>();

}
