258 |
258 |
for (File propFile : osgiInf.listFiles(IOUtils.FILTER_HIDDEN)) {
|
259 |
259 |
if (propFile.getName().startsWith("bundle") && propFile.getName().endsWith(".properties")) {
|
260 |
260 |
Properties props = new Properties();
|
261 |
|
props.load(IOUtils.getReader(propFile));
|
|
261 |
props.load(IOUtils.getReader(propFile, "ISO-8859-1"));
|
262 |
262 |
HashMap<String, String> h = new HashMap<String, String>();
|
263 |
263 |
for (Object k : props.keySet()) h.put(k.toString(), props.getProperty(k.toString()));
|
264 |
264 |
osgiLangs.put(propFile, h);
|
... | ... | |
549 |
549 |
langs.get(p).put(key, message);
|
550 |
550 |
}
|
551 |
551 |
}
|
552 |
|
|
553 |
552 |
|
|
553 |
|
554 |
554 |
public void putOSGI(String lang, String key, String message) {
|
555 |
555 |
osgiKeys.add(key);
|
556 |
556 |
|
... | ... | |
631 |
631 |
|
632 |
632 |
if (javaMessageFile == null) return;
|
633 |
633 |
|
634 |
|
//Write prop File
|
|
634 |
// 1 Write bundle*.properties prop File
|
|
635 |
for (File propFile : osgiLangs.keySet()) {
|
|
636 |
|
|
637 |
Properties props = new Properties() {
|
|
638 |
@Override
|
|
639 |
public synchronized Enumeration<Object> keys() {
|
|
640 |
TreeSet<Object> set = new TreeSet<Object>(comp);
|
|
641 |
set.addAll(super.keySet());
|
|
642 |
return Collections.enumeration(set);
|
|
643 |
}
|
|
644 |
};
|
|
645 |
HashMap<String, String> h = osgiLangs.get(propFile);
|
|
646 |
for (String k : h.keySet()) {
|
|
647 |
props.setProperty(k, h.get(k));
|
|
648 |
}
|
|
649 |
|
|
650 |
File newPropFile = new File(propFile.getParentFile(), propFile.getName()+".new");
|
|
651 |
if (replaceFiles) {
|
|
652 |
propFile.delete();
|
|
653 |
newPropFile = propFile;
|
|
654 |
}
|
|
655 |
props.store(IOUtils.getWriter(newPropFile, "ISO-8859-1"), "TXM OSGI messages generated by the PluginMessagesManager class");
|
|
656 |
}
|
|
657 |
|
|
658 |
// 2 Write messages*.properties prop File
|
635 |
659 |
for (File propFile : langs.keySet()) {
|
636 |
660 |
|
637 |
661 |
Properties props = new Properties() {
|
... | ... | |
655 |
679 |
props.store(IOUtils.getWriter(newPropFile, ENCODING), "TXM messages generated by the PluginMessagesManager class");
|
656 |
680 |
}
|
657 |
681 |
|
658 |
|
// write message File
|
|
682 |
// 3 write Java message File
|
659 |
683 |
File newJavaMessageFile = new File(javaMessageFile.getParentFile(), javaMessageFile.getName()+".new");
|
660 |
684 |
|
661 |
685 |
ArrayList<String> lines = IOUtils.getLines(javaMessageFile, "UFT-8");
|
662 |
686 |
TreeSet<String> oldKeys = new TreeSet<String>(IOUtils.findWithGroup(javaMessageFile, "public static String ([^\"=;]+);"));
|
663 |
687 |
TreeSet<String> newKeys = new TreeSet<String>(messageKeys);
|
664 |
688 |
TreeSet<String> writtenKeys = new TreeSet<String>();
|
665 |
|
|
|
689 |
|
666 |
690 |
newKeys.removeAll(oldKeys);
|
667 |
691 |
newKeys.removeAll(keyModifications.values()); // now contains only the very newly created keys
|
668 |
692 |
|