Revision 1327

tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/devtools/NormalizeKeys.java (revision 1327)
34 34
	 * Java keywords that can not be used as variable name.
35 35
	 * Also can not start by a number
36 36
	 */
37
	public static String javaKeyWords = "`^(abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|extends|false|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|native|new|null|package|private|protected|public|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|transient|true|try|void|volatile|while)$`i";
37
	public static String javaKeyWords = "`abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|extends|false|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|native|new|null|package|private|protected|public|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|transient|true|try|void|volatile|while`i";
38 38

  
39 39
	/**
40 40
	 * 
......
86 86
			}
87 87

  
88 88
			if (debug) System.out.print("K="+key+" ");
89
			if (key.equals("ComplexSort_4")) {
90
				System.out.println();
91
			}
89 92
			String newKeyOrig = normalize(messages.get(key));
90 93
			if (newKeyOrig.length() == 0) {
91 94
				//newKeyOrig = "EMPTY";
......
155 158
		str = str.replaceAll("%", "Percent");
156 159
		str = str.replaceAll("=", "Equals");
157 160
		str = str.replaceAll("@", "At");
161
		//str = str.replaceAll("&", "Amp");
158 162

  
159 163
		// remove all special chars
160 164
		str = str.replaceAll("[^a-zA-Z0-9 ]", "").trim();
......
199 203
		}
200 204

  
201 205
		// java variable can not start by a number or be a java keyword 
202
		if(str.matches(javaKeyWords) || str.matches("^[0-9].*$"))	{
206
		
207
		if(str.matches(javaKeyWords) 
208
				|| str.matches("^[0-9].*$"))	{
203 209
			str = "_" + str;
204 210
		}
205 211

  
206 212
		// log
207 213
		if(debug)	{
208 214
			System.out.println("   => " + str);
215
			System.out.println("   => " + str);
209 216
		}
210 217

  
211 218
		return str;
......
264 271

  
265 272
			total += keysNormalizer.normalize(pm);
266 273

  
267
			pm.saveChanges(true); // mode homme
274
			//pm.saveChanges(true); // mode homme
268 275
			//pm.saveChanges(false);
269 276

  
270 277
			if (pm.getProjectDirectory().getName().equals("org.txm.ca.rcp")) {
......
273 280
		}
274 281

  
275 282
		if (total > 0) {
276
			wmm.saveKeyModificationsInSources();
283
			//wmm.saveKeyModificationsInSources();
277 284
			System.out.println("Done: "+total+" changes.");
278 285
		} else {
279 286
			System.out.println("Done: no change.");

Also available in: Unified diff