Révision 1252

tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/devtools/NormalizeKeys.java (revision 1252)
43 43

  
44 44

  
45 45
	
46
	public BiHashMap<String, String> normalize(PluginMessages pmManager)	{
47

  
48
		BiHashMap<String, String> messages = pmManager.getMessagesForMainLang();
49
		
50
		for (String key : messages.getKeys()) {
51
			String value = messages.get(key);
52
			
53
			// already formatted message
54
			if(key.matches(preserve))	{
55
				System.err.println("NormalizeKeys.normalize(): warning: skipped: " + key + "=" + value);
56
				continue;
57
			}
58
			// empty message
59
			else if(value.length() == 0)	{
60
				System.err.println("NormalizeKeys.normalize(): warning: empty string for key: " + key); 
61
				continue;
62
			}
63
			
64
			messages.put(normalize(messages.get(key)), messages.get(key));
65
			//messages.removeByKey(key);
66
		}
67
		
68
		return messages;
69

  
70
	}
46 71
	
47 72
	
73
	
48 74
	/**
49 75
	 * Normalizes the keys of the specified messages map.
50 76
	 * @param messages
......
57 83
			
58 84
			// already formatted message
59 85
			if(key.matches(preserve))	{
60
				System.err.println("NormalizeKeys.normalize(): warning: skipped: " + key + " = " + value);
86
				System.err.println("NormalizeKeys.normalize(): warning: skipped: " + key + "=" + value);
61 87
				continue;
62 88
			}
63 89
			// empty message
......
96 122
			String[] words = str.split(" ");
97 123
			str = "";
98 124
			for (int i = 0; i < words.length; i++) {
99
				str += words[i].substring(0, 1).toUpperCase();
125
				if(words[i].length() == 0)	{
126
					continue;
127
				}
100 128
				try {
129
					str += words[i].substring(0, 1).toUpperCase();
130
				}
131
				catch (Exception e1) {
132
					// TODO Auto-generated catch block
133
					e1.printStackTrace();
134
				}
135
				try {
101 136
					str += words[i].substring(1);
102 137
				}
103 138
				catch (Exception e) {
......
140 175
			NormalizeKeys keysNormalizer = new NormalizeKeys(true);
141 176
			
142 177
			// tests
143
			keysNormalizer.normalize(pmManager.getMessagesForLang(""));
178
			keysNormalizer.normalize(pmManager);
144 179

  
145 180
			pmManager.dump(pmManager.getMessagesForLang(""));
146 181
			
tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/PluginMessages.java (revision 1252)
273 273
		return langs.get(p);
274 274
	}
275 275

  
276
	/**
277
	 * Gets the map of the messages keys and values for the main language.
278
	 * @return
279
	 */
280
	public BiHashMap<String, String> getMessagesForMainLang() {
281
		return this.getMessagesForLang("");
282
	}
276 283
	
284
	
277 285
	public void put(String lang, String key, String message) {
278 286
		messageKeys.add(key);
279 287

  

Formats disponibles : Unified diff