Mercurial > projects > dwt-win
comparison dwt/internal/Compatibility.d @ 317:8c656d6b7300
Add support for SWT language files
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 19 Oct 2008 01:26:56 +0200 |
parents | fd9c62a2998e |
children | f7a1b148cb35 |
comparison
equal
deleted
inserted
replaced
316:7cffa1a2985c | 317:8c656d6b7300 |
---|---|
293 */ | 293 */ |
294 public static void exec(String[] progArray) { | 294 public static void exec(String[] progArray) { |
295 auto proc = new Process( progArray ); | 295 auto proc = new Process( progArray ); |
296 proc.execute; | 296 proc.execute; |
297 } | 297 } |
298 /++ PORTING_LEFT | 298 |
299 const ImportData[] SWTMessagesBundleData = [ | |
300 getImportData!( "swt.internal.SWTMessages.properties" ), | |
301 getImportData!( "swt.internal.SWTMessages_ar.properties" ), | |
302 getImportData!( "swt.internal.SWTMessages_cs.properties" ), | |
303 getImportData!( "swt.internal.SWTMessages_da.properties" ), | |
304 getImportData!( "swt.internal.SWTMessages_de.properties" ), | |
305 getImportData!( "swt.internal.SWTMessages_el.properties" ), | |
306 getImportData!( "swt.internal.SWTMessages_es.properties" ), | |
307 getImportData!( "swt.internal.SWTMessages_fi.properties" ), | |
308 getImportData!( "swt.internal.SWTMessages_fr.properties" ), | |
309 getImportData!( "swt.internal.SWTMessages_hu.properties" ), | |
310 getImportData!( "swt.internal.SWTMessages_it.properties" ), | |
311 getImportData!( "swt.internal.SWTMessages_iw.properties" ), | |
312 getImportData!( "swt.internal.SWTMessages_ja.properties" ), | |
313 getImportData!( "swt.internal.SWTMessages_ko.properties" ), | |
314 getImportData!( "swt.internal.SWTMessages_nl.properties" ), | |
315 getImportData!( "swt.internal.SWTMessages_no.properties" ), | |
316 getImportData!( "swt.internal.SWTMessages_pl.properties" ), | |
317 getImportData!( "swt.internal.SWTMessages_pt_BR.properties" ), | |
318 getImportData!( "swt.internal.SWTMessages_pt.properties" ), | |
319 getImportData!( "swt.internal.SWTMessages_ru.properties" ), | |
320 getImportData!( "swt.internal.SWTMessages_sv.properties" ), | |
321 getImportData!( "swt.internal.SWTMessages_tr.properties" ), | |
322 getImportData!( "swt.internal.SWTMessages_zh_HK.properties" ), | |
323 getImportData!( "swt.internal.SWTMessages_zh.properties" ), | |
324 getImportData!( "swt.internal.SWTMessages_zh_TW.properties" ) | |
325 ]; | |
326 | |
299 private static ResourceBundle msgs = null; | 327 private static ResourceBundle msgs = null; |
300 | 328 |
301 /** | 329 /** |
302 * Returns the NLS'ed message for the given argument. This is only being | 330 * Returns the NLS'ed message for the given argument. This is only being |
303 * called from DWT. | 331 * called from DWT. |
308 * @see DWT#getMessage(String) | 336 * @see DWT#getMessage(String) |
309 */ | 337 */ |
310 public static String getMessage(String key) { | 338 public static String getMessage(String key) { |
311 String answer = key; | 339 String answer = key; |
312 | 340 |
313 if (key == null) { | 341 if (key is null) { |
314 DWT.error (DWT.ERROR_NULL_ARGUMENT); | 342 DWT.error (DWT.ERROR_NULL_ARGUMENT); |
315 } | 343 } |
316 if (msgs == null) { | 344 if (msgs is null) { |
317 try { | 345 try { |
318 msgs = ResourceBundle.getBundle("dwt.internal.SWTMessages"); //$NON-NLS-1$ | 346 msgs = ResourceBundle.getBundle(SWTMessagesBundleData); //$NON-NLS-1$ |
319 } catch (MissingResourceException ex) { | 347 } catch (MissingResourceException ex) { |
320 answer = key + " (no resource bundle)"; //$NON-NLS-1$ | 348 answer = key ~ " (no resource bundle)"; //$NON-NLS-1$ |
321 } | 349 } |
322 } | 350 } |
323 if (msgs != null) { | 351 if (msgs !is null) { |
324 try { | 352 try { |
325 answer = msgs.getString(key); | 353 answer = msgs.getString(key); |
326 } catch (MissingResourceException ex2) {} | 354 } catch (MissingResourceException ex2) {} |
327 } | 355 } |
328 return answer; | 356 return answer; |
329 } | 357 } |
330 | 358 |
331 public static String getMessage(String key, Object[] args) { | 359 public static String getMessage(String key, Object[] args) { |
332 String answer = key; | 360 String answer = key; |
333 | 361 |
334 if (key == null || args == null) { | 362 if (key is null || args is null) { |
335 DWT.error (DWT.ERROR_NULL_ARGUMENT); | 363 DWT.error (DWT.ERROR_NULL_ARGUMENT); |
336 } | 364 } |
337 if (msgs == null) { | 365 if (msgs is null) { |
338 try { | 366 try { |
339 msgs = ResourceBundle.getBundle("dwt.internal.SWTMessages"); //$NON-NLS-1$ | 367 msgs = ResourceBundle.getBundle(SWTMessagesBundleData); //$NON-NLS-1$ |
340 } catch (MissingResourceException ex) { | 368 } catch (MissingResourceException ex) { |
341 answer = key + " (no resource bundle)"; //$NON-NLS-1$ | 369 answer = key ~ " (no resource bundle)"; //$NON-NLS-1$ |
342 } | 370 } |
343 } | 371 } |
344 if (msgs != null) { | 372 if (msgs !is null) { |
345 try { | 373 try { |
346 MessageFormat formatter = new MessageFormat(""); | 374 char[] frmt = msgs.getString(key); |
347 formatter.applyPattern(msgs.getString(key)); | 375 switch( args.length ){ |
348 answer = formatter.format(args); | 376 case 0: answer = Format(frmt); break; |
377 case 1: answer = Format(frmt, args[0]); break; | |
378 case 2: answer = Format(frmt, args[0], args[1]); break; | |
379 case 3: answer = Format(frmt, args[0], args[1], args[2]); break; | |
380 case 4: answer = Format(frmt, args[0], args[1], args[2], args[3]); break; | |
381 case 5: answer = Format(frmt, args[0], args[1], args[2], args[3], args[4]); break; | |
382 default: | |
383 implMissing(__FILE__, __LINE__ ); | |
384 } | |
349 } catch (MissingResourceException ex2) {} | 385 } catch (MissingResourceException ex2) {} |
350 } | 386 } |
351 return answer; | 387 return answer; |
352 } | 388 } |
353 ++/ | |
354 | 389 |
355 | 390 |
356 /** | 391 /** |
357 * Interrupt the current thread. | 392 * Interrupt the current thread. |
358 * <p> | 393 * <p> |