Révision 1241
tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/PluginMessages.java (revision 1241) | ||
---|---|---|
10 | 10 |
import java.io.UnsupportedEncodingException; |
11 | 11 |
import java.util.ArrayList; |
12 | 12 |
import java.util.Arrays; |
13 |
import java.util.Collection; |
|
14 |
import java.util.Collections; |
|
13 | 15 |
import java.util.HashMap; |
14 | 16 |
import java.util.LinkedHashSet; |
15 | 17 |
import java.util.Map; |
... | ... | |
158 | 160 |
public void createUsedKeysIndex() { |
159 | 161 |
this.usedKeysIndex = new HashMap<String, TreeSet<File>>(); |
160 | 162 |
|
161 |
//ArrayList<String> unusedKeys = new ArrayList<String>(); |
|
162 | 163 |
for (String key : messageKeys) { |
163 | 164 |
|
164 | 165 |
TreeSet<File> files = new TreeSet<File>(); |
... | ... | |
167 | 168 |
if(debug) { |
168 | 169 |
System.out.println("PluginMessages.createUsedKeysIndex(): cheking key " + key + "..."); |
169 | 170 |
} |
170 |
|
|
171 |
//HashMap<File, String> files = new HashMap<File, String>(); |
|
172 | 171 |
|
173 | 172 |
for (File file : this.srcFiles) { |
174 | 173 |
ArrayList<String> lines = IOUtils.getLines(file, PluginMessages.ENCODING); |
... | ... | |
180 | 179 |
|
181 | 180 |
} |
182 | 181 |
} |
183 |
|
|
184 |
// if (filesUsingKey.isEmpty()) { |
|
185 |
// unusedKeys.add(key); |
|
186 |
// } |
|
187 | 182 |
} |
188 |
|
|
189 |
// return unusedKeys; |
|
190 | 183 |
this.dumpUsedKeysIndex(); |
191 |
|
|
192 | 184 |
} |
193 | 185 |
|
194 | 186 |
|
... | ... | |
236 | 228 |
// } |
237 | 229 |
// |
238 | 230 |
// |
239 |
// /**
|
|
240 |
// * Returns the keys of all messages that are not used in the project itself.
|
|
241 |
// * @return
|
|
242 |
// */
|
|
243 |
// public ArrayList<String> findUnusedKeys() {
|
|
244 |
// ArrayList<String> unusedKeys = new ArrayList<String>();
|
|
245 |
// for (String key : messageKeys) {
|
|
246 |
//
|
|
247 |
// if(debug) { |
|
248 |
// System.out.println("PluginMessages.findUnsedKeys(): cheking key " + key + "...");
|
|
249 |
// }
|
|
250 |
//
|
|
251 |
// HashMap<File, String> filesUsingKey = this.getFilesUsingKey(key); |
|
252 |
// if (filesUsingKey.isEmpty()) {
|
|
253 |
// unusedKeys.add(key);
|
|
254 |
// }
|
|
255 |
// } |
|
256 |
//
|
|
257 |
// return unusedKeys;
|
|
258 |
// }
|
|
231 |
/** |
|
232 |
* Returns the keys of all messages that are not used in the project itself. |
|
233 |
* @return a sorted list containing all unused keys
|
|
234 |
*/ |
|
235 |
public ArrayList<String> findUnusedKeys() { |
|
236 |
ArrayList<String> unusedKeys = new ArrayList<String>(); |
|
237 |
for (Map.Entry<String, TreeSet<File>> entry : this.usedKeysIndex.entrySet()) {
|
|
238 |
if(entry.getValue().isEmpty()) {
|
|
239 |
|
|
240 |
if(debug) {
|
|
241 |
System.out.println("PluginMessages.findUnusedKeys(): unused key found: " + entry.getKey() + ".");
|
|
242 |
}
|
|
243 |
|
|
244 |
unusedKeys.add(entry.getKey());
|
|
245 |
}
|
|
246 |
} |
|
247 |
|
|
248 |
Collections.sort(unusedKeys);
|
|
249 |
return unusedKeys; |
|
250 |
} |
|
259 | 251 |
|
260 | 252 |
|
261 | 253 |
/** |
... | ... | |
524 | 516 |
// System.out.println("find files using key: file " + entry.getKey() + " contains key " + entry.getValue()); |
525 | 517 |
// } |
526 | 518 |
// |
527 |
// // test to find unused keys
|
|
528 |
// ArrayList<String> unusedKeys = pmManager.findUnusedKeys();
|
|
529 |
// for (int i = 0; i < unusedKeys.size(); i++) {
|
|
530 |
// System.out.println("findUnusedKeys: key " + unusedKeys.get(i) + " is unused in project " + pmManager.getProjectDirectory() + " (main language value = " + pmManager.getMessagesForLang("").get(unusedKeys.get(i)) + ")");
|
|
531 |
// }
|
|
519 |
// test to find unused keys |
|
520 |
ArrayList<String> unusedKeys = pmManager.findUnusedKeys(); |
|
521 |
for (int i = 0; i < unusedKeys.size(); i++) { |
|
522 |
System.out.println("findUnusedKeys: key " + unusedKeys.get(i) + " is unused in project " + pmManager.getProjectDirectory() + " (main language value = " + pmManager.getMessagesForLang("").get(unusedKeys.get(i)) + ")"); |
|
523 |
} |
|
532 | 524 |
|
533 | 525 |
//dict.summary(); |
534 | 526 |
//dict.saveChanges(); |
Formats disponibles : Unified diff