blob: fbb0ebce3f333c60d371683eccc7cb676a403589 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*******************************************************************************
* Copyright (c) 2005, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.metatype.impl;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class LocalizationElement {
public static final char KEY_SIGN = '%';
String _localization = null;
ResourceBundle _rb;
/**
* Internal method
*/
void setResourceBundle(ResourceBundle rb) {
this._rb = rb;
}
/**
* Method to get the localized text of inputed String.
*/
String getLocalized(String key) {
if (key == null) {
return null;
}
if ((key.length() > 1) && (key.charAt(0) == KEY_SIGN)) {
if (_rb != null) {
try {
String transfered = _rb.getString(key.substring(1));
if (transfered != null) {
return transfered;
}
} catch (MissingResourceException mre) {
// Nothing found for this key.
}
}
// If no localization file available or no localized value found
// for the key, then return the raw data without the key-sign.
return key.substring(1);
}
return key;
}
}
|