129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2007, 2008 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwtx.jface.text.TextMessages;
|
|
14
|
|
15 import dwt.dwthelper.utils;
|
|
16
|
|
17 import java.util.MissingResourceException;
|
|
18 import java.util.ResourceBundle;
|
|
19
|
|
20 import com.ibm.icu.text.MessageFormat;
|
|
21
|
|
22
|
|
23 /**
|
|
24 * Helper class to get NLSed messages.
|
|
25 *
|
|
26 * @since 3.4
|
|
27 */
|
|
28 class TextMessages {
|
|
29 private static final String BUNDLE_NAME= "dwtx.jface.text.TextMessages"; //$NON-NLS-1$
|
|
30
|
|
31 private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
|
|
32
|
|
33 private TextMessages() {
|
|
34 }
|
|
35
|
|
36 public static String getString(String key) {
|
|
37 try {
|
|
38 return RESOURCE_BUNDLE.getString(key);
|
|
39 } catch (MissingResourceException e) {
|
|
40 return '!' + key + '!';
|
|
41 }
|
|
42 }
|
|
43
|
|
44 public static String getFormattedString(String key, Object arg) {
|
|
45 return getFormattedString(key, new Object[] { arg });
|
|
46 }
|
|
47
|
|
48 public static String getFormattedString(String key, Object[] args) {
|
|
49 return MessageFormat.format(getString(key), args);
|
|
50 }
|
|
51
|
|
52 }
|