(22.4.2010 6 Keys are not translated, in the svn)
I'll update de_stringtable.txt with every package of files to commit i send geoff
I wrote my self a little java class allowing to add new entries and resorting the translated file to the english key order, in order to reach a complete translation.
Perhaps some people doing translations may find it usefull.
Change it at will, no guarantees:
Code: Select all
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.Properties;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class MainWindow extends JFrame implements ActionListener {
public static void main(String[] args) {
new MainWindow();
}
private JButton btnMerge;
private JLabel lblResult;
private JLabel lblPrimary;
private JTextField txtPrimary;
private JLabel lblSecondary;
private JTextField txtSecondary;
private JLabel lblTarget;
private JTextField txtTarget;
private MainWindow() {
setLayout(new GridLayout(4,2));
btnMerge = new JButton("merge");
btnMerge.addActionListener(this);
lblResult = new JLabel("new entries: ?");
lblPrimary = new JLabel("nativ file (used for comments and structure)");
lblSecondary = new JLabel("foreign file (used for translations)");
lblTarget = new JLabel("target file (will be overwritten)");
txtPrimary = new JTextField("D:/FreeOrion_SDK/FreeOrion/default/eng_stringtable.txt");
txtSecondary = new JTextField("D:/FreeOrion_SDK/FreeOrion/default/de_stringtable.txt");
txtTarget = new JTextField("C:/Temp/test.txt");
getContentPane().add(lblPrimary);
getContentPane().add(txtPrimary);
getContentPane().add(lblSecondary);
getContentPane().add(txtSecondary);
getContentPane().add(lblTarget);
getContentPane().add(txtTarget);
getContentPane().add(btnMerge);
getContentPane().add(lblResult);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
try {
lblResult.setText("new entries: " + merge(
new FileReader(txtPrimary.getText()),
new FileReader(txtSecondary.getText()),
new FileWriter(txtTarget.getText())
));
} catch (IOException e) {
e.printStackTrace();
}
}
public int merge( Reader a, Reader b, Writer c) throws IOException {
BufferedReader ba = new BufferedReader(a);
BufferedReader bb = new BufferedReader(b);
int count = 0;
String key = "";
String value = "";
String line = "";
String comment = "";
Properties values = new Properties();
Properties comments = new Properties();
boolean complete = false;
line = bb.readLine();
//write header
c.write(line);
c.write("\n");
while(bb.ready()) {
line = bb.readLine();
if(line.trim().equals("")) {
comment = comment + line + "\n";
} else if(line.charAt(0) == '#') {
comment = comment + line +"\n";
}else if (key.equals("")) {
//key
key = line.trim();
} else if(line.trim().startsWith("'''")) {
//value
value = line;
while (!value.trim().endsWith("'''") || value.trim().length() <= 3) {
line = bb.readLine();
value += "\n" + line;
}
complete = true;
} else {
value = line;
complete = true;
}
if (complete) {
values.setProperty(key, value);
comments.setProperty(key, comment);
key = "";
value = "";
comment = "";
complete = false;
}
}
//dicard header
line = ba.readLine();
while(ba.ready()) {
line = ba.readLine();
if(line.trim().equals("")) {
comment = comment + line + "\n";
} else if(line.charAt(0) == '#') {
comment = comment + line +"\n";
}else if (key.equals("")) {
//key
key = line.trim();
} else if(line.trim().startsWith("'''")) {
//value
value = line;
while (!value.trim().endsWith("'''") || value.trim().length() <= 3) {
line = ba.readLine();
value += "\n" + line;
}
complete = true;
} else {
value = line;
complete = true;
}
if (complete) {
line = comments.getProperty(key);
if (line == null || line.equals("")) {
c.write(comment);
} else {
c.write(comments.getProperty(key));
}
c.write(key);
c.write("\n");
line = values.getProperty(key);
if (line == null) {
c.write("TODO!" + value);
c.write("\n");
count ++;
} else {
c.write(line);
c.write("\n");
}
key = "";
value = "";
comment = "";
complete = false;
}
}
c.flush();
return count;
}
}