Commit 656d3a6d authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

I forgot comitting the actual language handling class

parent 1169d4ec
/*****************************************************************************
* Language.java
*****************************************************************************
* Copyright (C) 2007 Daniel Dreibrodt
*
* VLC Skin Editor
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
package vlcskineditor;
import java.io.*;
import java.util.Hashtable;
/**
* Class to manage the multi-language interface
* @author Daniel Dreibrodt
*/
public class Language {
private static Hashtable<String, String> strings = new Hashtable<String, String>();
public static void loadLanguage(File f) {
try {
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
//Readers have been initiated successfully, thus the file exists and the former table can be cleared
strings.clear();
String line = "";
while( (line = br.readLine()) != null) {
if(!line.startsWith("#")) {
String[] fields = line.split("\\|");
if(fields.length==2) {
strings.put(fields[0], fields[1].replaceAll("\\\\n", "\n"));
}
}
}
} catch(FileNotFoundException ex) {
ex.printStackTrace();
} catch(IOException ex) {
ex.printStackTrace();
}
}
public static String getString(String key) {
String s = strings.get(key);
return (s!=null)?s:key;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment