Mercurial > projects > dwt2
comparison org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLMessages.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children | ebefa5c2eab4 |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2006 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 org.eclipse.jface.internal.text.html.HTMLMessages; | |
14 | |
15 import org.eclipse.jface.internal.text.html.HTML2TextReader; // packageimport | |
16 import org.eclipse.jface.internal.text.html.HTMLPrinter; // packageimport | |
17 import org.eclipse.jface.internal.text.html.BrowserInformationControl; // packageimport | |
18 import org.eclipse.jface.internal.text.html.SubstitutionTextReader; // packageimport | |
19 import org.eclipse.jface.internal.text.html.HTMLTextPresenter; // packageimport | |
20 import org.eclipse.jface.internal.text.html.BrowserInput; // packageimport | |
21 import org.eclipse.jface.internal.text.html.SingleCharReader; // packageimport | |
22 import org.eclipse.jface.internal.text.html.BrowserInformationControlInput; // packageimport | |
23 | |
24 | |
25 import java.lang.all; | |
26 | |
27 import java.util.ResourceBundle; | |
28 import java.util.MissingResourceException; | |
29 import java.text.MessageFormat; | |
30 | |
31 | |
32 /** | |
33 * Helper class to get NLSed messages. | |
34 * | |
35 * @since 3.3 | |
36 */ | |
37 class HTMLMessages { | |
38 | |
39 // private static const String RESOURCE_BUNDLE= HTMLMessages.classinfo.getName(); | |
40 | |
41 private static ResourceBundle fgResourceBundle;//= ResourceBundle.getBundle(RESOURCE_BUNDLE); | |
42 | |
43 static this() { | |
44 fgResourceBundle = ResourceBundle.getBundle( | |
45 getImportData!("org.eclipse.jface.internal.text.html.HTMLMessages.properties")); | |
46 } | |
47 | |
48 private this() { | |
49 } | |
50 | |
51 /** | |
52 * Gets a string from the resource bundle. | |
53 * | |
54 * @param key the string used to get the bundle value, must not be null | |
55 * @return the string from the resource bundle | |
56 */ | |
57 public static String getString(String key) { | |
58 try { | |
59 return fgResourceBundle.getString(key); | |
60 } catch (MissingResourceException e) { | |
61 return "!" ~ key ~ "!";//$NON-NLS-2$ //$NON-NLS-1$ | |
62 } | |
63 } | |
64 | |
65 /** | |
66 * Gets a string from the resource bundle and formats it with the given arguments. | |
67 * | |
68 * @param key the string used to get the bundle value, must not be null | |
69 * @param args the arguments used to format the string | |
70 * @return the formatted string | |
71 */ | |
72 public static String getFormattedString(String key, Object[] args...) { | |
73 String format= null; | |
74 try { | |
75 format= fgResourceBundle.getString(key); | |
76 } catch (MissingResourceException e) { | |
77 return "!" ~ key ~ "!";//$NON-NLS-2$ //$NON-NLS-1$ | |
78 } | |
79 return MessageFormat.format(format, args); | |
80 } | |
81 | |
82 } |