Fixing the translation problem in the content center (see #1630).

git-svn-id: https://svn.libreccm.org/ccm/trunk@2085 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-03-16 09:49:19 +00:00
parent de925fdb3b
commit 9b263bec1a
11 changed files with 400 additions and 346 deletions

View File

@ -1113,3 +1113,10 @@ cms.ui.clear=Clear
cms.ui.item_search.create.folder_missing=No folder selected
cms.ui.images_links=
cms.contenttypes.ui.person.alias.delete.label=Delete
cms.ui.contentcenter.mainpage.search=Search
cms.ui.contentcenter.mainpage.taskssections=Tasks/Sections
cms.ui.contentcenter.section=Section
cms.ui.contentcenter.action=Action
cms.ui.set_home_folder=Set as home folder
cms.ui.go_to_home_folder=Go to home folder
cms.ui.no_home_folder_selected=No home folder selected

View File

@ -845,7 +845,7 @@ cms.ui.workflow.tasks=Aufgaben
cms.ui.workflow.task.view_locked=Reservierte Aufgaben anzeigen
cms.ui.workflow.task.view_unlocked=Freigegebene Aufgaben anzeigen
cms.ui.workflow.task.view_all=Alle Aufgaben anzeigen
cms.ui.workflow.task.item_title=Item Title
cms.ui.workflow.task.item_title=Titel des Dokuments
cms.ui.workflow.task.locking_user=Reserviert von\:
cms.ui.workflow.unlock_tasks=Alle meine Aufgaben f\u00fcr diesen Typ freigeben
cms.ui.workflow.your_tasks=Zugewiesene Aufgaben
@ -1105,4 +1105,11 @@ cms.ui.type.minimum_number_of_values_bigger_than_maximum_number_of_values=Maxima
cms.ui.type.minimummaximum_number_of_values_cannot_be_negative=Keine negativen Werte erlaubt
cms.ui.item_search.create.folder_missing=kein Ordner ausgew\u00e4hlt
cms.ui.images_links=
cms.contenttypes.ui.person.alias.delete.label=
cms.contenttypes.ui.person.alias.delete.label=L\u00f6schen
cms.ui.contentcenter.mainpage.search=Suche
cms.ui.contentcenter.mainpage.taskssections=Aufgaben/Content Sections
cms.ui.contentcenter.section=Content Section
cms.ui.contentcenter.action=Aktion
cms.ui.set_home_folder=Als Start-Ordner festlegen
cms.ui.go_to_home_folder=Zum Start-Ordner
cms.ui.no_home_folder_selected=Kein Start-Ordner festgelegt

View File

@ -52,3 +52,10 @@ cms.ui.clear=
cms.ui.item_search.create.folder_missing=
cms.ui.images_links=
cms.contenttypes.ui.person.alias.delete.label=
cms.ui.contentcenter.mainpage.search=
cms.ui.contentcenter.mainpage.taskssections=
cms.ui.contentcenter.section=
cms.ui.contentcenter.action=
cms.ui.set_home_folder=
cms.ui.go_to_home_folder=
cms.ui.no_home_folder_selected=

View File

@ -583,3 +583,10 @@ cms.ui.clear=
cms.ui.item_search.create.folder_missing=
cms.ui.images_links=
cms.contenttypes.ui.person.alias.delete.label=
cms.ui.contentcenter.mainpage.search=
cms.ui.contentcenter.mainpage.taskssections=
cms.ui.contentcenter.section=
cms.ui.contentcenter.action=
cms.ui.set_home_folder=
cms.ui.go_to_home_folder=
cms.ui.no_home_folder_selected=

View File

@ -18,7 +18,6 @@
*/
package com.arsdigita.cms.ui;
import com.arsdigita.bebop.ActionLink;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormProcessException;
@ -92,34 +91,27 @@ public class FlatItemList extends SegmentedPanel
private static final String CMS_PRIVILEGES = "com.arsdigita.cms.getPrivileges";
private static final String PRIVILEGE = "privilege";
private static final String PRIVILEGE_NAME = "prettyName";
// The folder selectors
private FolderSelectionModel m_folderSel;
private FolderRequestLocal m_folder;
private NewItemForm m_newItem;
private SingleSelectionModel m_typeSel;
private CreationSelector m_selector;
private FolderManipulator m_folderManip;
private FolderCreator m_folderCreator;
private ActionLink m_setHomeFolderAction;
private ActionLink m_createFolderAction;
private ActionLink m_togglePrivateAction;
private Label m_homeFolderLabel;
private Segment m_browseSeg;
private Segment m_newItemSeg;
private Segment m_newFolderSeg;
private Segment m_editFolderSeg;
private Segment m_permissionsSeg;
private CMSPermissionsPane m_permPane;
// Folder edit/rename functionality.
private ActionLink m_editFolderAction;
private FolderEditor m_folderEditor;
private Label m_contentLabel;
private ItemPath m_itemPath;
private Label m_chooseLabel;
@ -139,6 +131,7 @@ public class FlatItemList extends SegmentedPanel
PageState s = e.getPageState();
reset(s);
}
});
setIdAttr("flat-item-list");
@ -189,7 +182,7 @@ public class FlatItemList extends SegmentedPanel
m_editFolderAction.addActionListener(this);
browseActions.addAction(m_editFolderAction);
m_setHomeFolderAction = new ActionLink(new Label("Set as home folder"));
m_setHomeFolderAction = new ActionLink(new Label(globalize("cms.ui.set_home_folder")));
m_setHomeFolderAction.addActionListener(this);
browseActions.addAction(m_setHomeFolderAction);
@ -200,13 +193,21 @@ public class FlatItemList extends SegmentedPanel
Folder folder = Folder.getUserHomeFolder(user, CMS.getContext().getContentSection());
if (folder != null) {
String url = folder.getContentSection().getURL() + PageLocations.SECTION_PAGE + "?" + ContentSectionPage.SET_FOLDER + "=" + folder.getID();
label.setLabel("Go to home folder: <a href=\"" + url + "\">" + folder.getLabel() + "</a>");
String url = folder.getContentSection().getURL() + PageLocations.SECTION_PAGE + "?"
+ ContentSectionPage.SET_FOLDER + "=" + folder.getID();
//label.setLabel("Go to home folder: <a href=\"" + url + "\">" + folder.getLabel() + "</a>");
label.setLabel(String.format("%s: <a href=\"%s\">%s</a>",
(String) globalize("cms.ui.go_to_home_folder").localize(),
url,
folder.getLabel()));
} else {
label.setLabel("<font color=\"red\">No home folder selected</font>");
//label.setLabel("<font color=\"red\">No home folder selected</font>");
label.setLabel(String.format("<span style=\"color: red\">%s</span>",
(String)globalize("cms.ui.no_home_folder_selected").localize()));
}
label.setOutputEscaping(false);
}
});
browseActions.addAction(m_homeFolderLabel);
@ -236,9 +237,8 @@ public class FlatItemList extends SegmentedPanel
}
query.close();
m_permPane = new CMSPermissionsPane
((PrivilegeDescriptor[]) privs.toArray
(new PrivilegeDescriptor[privs.size()]),
m_permPane =
new CMSPermissionsPane((PrivilegeDescriptor[]) privs.toArray(new PrivilegeDescriptor[privs.size()]),
privNameMap,
m_folderSel);
permActions.setSubject(m_permPane);
@ -253,11 +253,13 @@ public class FlatItemList extends SegmentedPanel
// ACSObject parent = currentFolder.getParent();
DataObject context = PermissionService.getContext(currentFolder);
if (context == null) {
target.setLabel( (String) GlobalizationUtil.globalize("cms.ui.restore_default_permissions").localize());
target.setLabel((String) GlobalizationUtil.globalize("cms.ui.restore_default_permissions").
localize());
} else {
target.setLabel((String) GlobalizationUtil.globalize("cms.ui.use_custom_permissions").localize());
}
}
}));
m_togglePrivateAction.addActionListener(this);
permActions.addAction(m_togglePrivateAction);
@ -311,6 +313,7 @@ public class FlatItemList extends SegmentedPanel
showHideSegments(state);
}
}
});
}
@ -436,8 +439,7 @@ public class FlatItemList extends SegmentedPanel
} else if (source == m_editFolderAction) {
m_permissionsSeg.setVisible(s, false);
m_editFolderSeg.setVisible(s, true);
}
else if (source == m_togglePrivateAction) {
} else if (source == m_togglePrivateAction) {
togglePermissions(s);
} else if (source == m_setHomeFolderAction) {
User user = Web.getContext().getUser();
@ -470,8 +472,8 @@ public class FlatItemList extends SegmentedPanel
if (section != null) {
PermissionService.setContext(currentFolder, section);
} else {
throw new IllegalStateException("Cannot set the context for a folder with " +
"no parent and no Content Section");
throw new IllegalStateException("Cannot set the context for a folder with "
+ "no parent and no Content Section");
}
}
@ -485,8 +487,8 @@ public class FlatItemList extends SegmentedPanel
if (liveSection != null) {
PermissionService.setContext(liveVersion, liveSection);
} else {
throw new IllegalStateException("Cannot set the context for a folder with " +
"no parent and no Content Section");
throw new IllegalStateException("Cannot set the context for a folder with "
+ "no parent and no Content Section");
}
}
}
@ -505,7 +507,8 @@ public class FlatItemList extends SegmentedPanel
ObjectPermissionCollection livePerms = PermissionService.getGrantedPermissions(liveVersion.getOID());
while (livePerms.next()) {
if (!livePerms.isInherited()) {
PermissionDescriptor desc2 = new PermissionDescriptor(livePerms.getPrivilege(), liveVersion.getOID(),
PermissionDescriptor desc2 = new PermissionDescriptor(livePerms.getPrivilege(), liveVersion.
getOID(),
livePerms.getGranteeOID());
PermissionService.revokePermission(desc2);
}
@ -549,6 +552,7 @@ public class FlatItemList extends SegmentedPanel
public ContentSection getContentSection(PageState s) {
return CMS.getContext().getContentSection();
}
}
/**

View File

@ -85,7 +85,7 @@ public abstract class NewItemForm extends Form {
m_emptyLabel.setIdAttr("empty_label");
panel.add(m_emptyLabel);
m_createLabel = new Label(globalize("cms.ui.authoring.create_new"), false);
m_createLabel = new Label((String)globalize("cms.ui.authoring.create_new").localize(), false);
m_createLabel.setIdAttr("create_label");
panel.add(m_createLabel);

View File

@ -291,7 +291,11 @@ public class ContentSectionContainer extends CMSContainer {
// add columns to the table
TableColumnModel columnModel = getColumnModel();
TableColumn contentSectionColumn = new TableColumn(colNo, COLUMN_SECTION);
//TableColumn contentSectionColumn = new TableColumn(colNo, COLUMN_SECTION);
TableColumn contentSectionColumn = new TableColumn(
colNo,
(String)GlobalizationUtil.globalize("cms.ui.contentcenter.section").localize(),
COLUMN_SECTION);
contentSectionColumn.setCellRenderer(new AdminURLTableCellRenderer());
columnModel.add(contentSectionColumn);
@ -302,7 +306,10 @@ public class ContentSectionContainer extends CMSContainer {
columnModel.add(locationColumn);
}
TableColumn actionColumn = new TableColumn(colNo ++, COLUMN_ACTION);
TableColumn actionColumn = new TableColumn(
colNo++,
(String)GlobalizationUtil.globalize("cms.ui.contentcenter.action").localize(),
COLUMN_ACTION);
actionColumn.setCellRenderer(new ActionTableCellRenderer());
columnModel.add(actionColumn);

View File

@ -145,8 +145,14 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
protected TabbedPane createTabbedPane() {
TabbedPane pane = new TabbedPane();
pane.setClassAttr(XSL_CLASS);
addToPane(pane, "Tasks/Sections", getTasksPane(m_typeSel, m_sectionSel));
addToPane(pane, "Search", getSearchPane());
//addToPane(pane, "Tasks/Sections", getTasksPane(m_typeSel, m_sectionSel));
//addToPane(pane, "Search", getSearchPane());
addToPane(pane,
(String)GlobalizationUtil.globalize("cms.ui.contentcenter.mainpage.taskssections").localize(),
getTasksPane(m_typeSel, m_sectionSel));
addToPane(pane,
(String)GlobalizationUtil.globalize("cms.ui.contentcenter.mainpage.search").localize(),
getSearchPane());
pane.addActionListener(this);
return pane;
}

View File

@ -18,7 +18,6 @@
*/
package com.arsdigita.cms.ui.contentcenter;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.HashMap;
@ -90,13 +89,10 @@ public class TasksPanel extends CMSContainer {
private static Logger s_log =
Logger.getLogger(TasksPanel.class);
// The default number of rows to show
private static final int DEFAULT_MAX_ROWS = 15;
// Number of tasks to show
private final int m_maxRows;
private TaskList m_taskList;
private ActionLink m_viewAllLink;
private ActionLink m_viewShortLink;
@ -106,12 +102,10 @@ public class TasksPanel extends CMSContainer {
private StringParameter m_sortDirectionParam;
private StringParameter m_sortTypeParam;
private StringParameter m_lockFilterParam;
// control link variable
private static final String TASK_ACTION = "taskAction";
private static final String SORT_DOWN = "sortActionUp";
private static final String SORT_UP = "sortActionDown";
private static final String LOCK_FILTER_TYPE = "lockFilterType";
private static final String SORT_TYPE = "sortType";
private static final String SORT_DIRECTION = "sortDirection";
@ -121,13 +115,11 @@ public class TasksPanel extends CMSContainer {
private static final String SORT_TITLE = "title";
private static final String SORT_USER = "user";
private static final String SORT_WORKFLOW = "workflow";
// IMAGES
public static final String UP_ARROW_IMAGE =
"/themes/heirfloom/images/gray-triangle-up.gif";
public static final String DOWN_ARROW_IMAGE =
"/themes/heirfloom/images/gray-triangle-down.gif";
// CREATION PANE CONSTANTS
private Label m_selectorLabel;
private CreationSelector m_selector;
@ -168,7 +160,6 @@ public class TasksPanel extends CMSContainer {
addComponents();
}
/**
* Adds the components to this tasks panel
**/
@ -197,6 +188,7 @@ public class TasksPanel extends CMSContainer {
t.setFontWeight(Label.BOLD);
t.setClassAttr("creationLabel");
}
});
m_selectorLabel.setClassAttr("creationLabel");
m_creationPane.add(m_selectorLabel);
@ -222,36 +214,37 @@ public class TasksPanel extends CMSContainer {
m_sections.setVisible(s, !isSelected);
m_creationPane.setVisible(s, isSelected);
}
});
m_viewLockLink = new ActionLink(new
Label(GlobalizationUtil
m_viewLockLink = new ActionLink(new Label(GlobalizationUtil
.globalize("cms.ui.workflow.task.view_locked")));
m_viewLockLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
ps.setValue(m_lockFilterParam, "lock");
}
});
m_viewUnlockLink = new ActionLink(new
Label(GlobalizationUtil
m_viewUnlockLink = new ActionLink(new Label(GlobalizationUtil
.globalize("cms.ui.workflow.task.view_unlocked")));
m_viewUnlockLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
ps.setValue(m_lockFilterParam, "unlock");
}
});
m_viewAllLockLink = new ActionLink(new
Label(GlobalizationUtil
m_viewAllLockLink = new ActionLink(new Label(GlobalizationUtil
.globalize("cms.ui.workflow.task.view_all")));
m_viewAllLockLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
ps.setValue(m_lockFilterParam, "all");
}
});
m_viewLockLabel = new Label(GlobalizationUtil
@ -331,6 +324,7 @@ public class TasksPanel extends CMSContainer {
m_viewAllLockLink.setVisible(state, false);
}
}
});
}
@ -347,7 +341,6 @@ public class TasksPanel extends CMSContainer {
return m_paginator;
}
/**
* Returns the bebop List component to display the tasks
**/
@ -433,6 +426,7 @@ public class TasksPanel extends CMSContainer {
private static class RootFolderSelectionModel
extends FolderSelectionModel {
ACSObjectSelectionModel m_sectionSel;
public RootFolderSelectionModel(ACSObjectSelectionModel sectionSel) {
@ -454,9 +448,11 @@ public class TasksPanel extends CMSContainer {
}
return sec.getRootFolder().getID();
}
}
private class TasksPaginationModelBuilder implements PaginationModelBuilder {
public int getTotalSize(Paginator paginator,
PageState state) {
return numberTasksForUser(state);
@ -465,13 +461,13 @@ public class TasksPanel extends CMSContainer {
public boolean isVisible(PageState state) {
return numberTasksForUser(state) > m_maxRows;
}
}
private class TaskList extends SimpleComponent {
private final static String QUERY_NAME =
"com.arsdigita.cms.workflow.getEnabledUserTasks";
private boolean m_paginate = false;
public TaskList(boolean paginate) {
@ -498,6 +494,7 @@ public class TasksPanel extends CMSContainer {
DataQuery query = makeQuery(state);
return new Long(query.size());
}
};
@Override
@ -524,30 +521,21 @@ public class TasksPanel extends CMSContainer {
}
if (sortKey.equals(SORT_TITLE)) {
query.setOrder("lower(pageTitle) " + sortPostfix +
", lower(status) asc, dueDate desc");
query.setOrder("lower(pageTitle) " + sortPostfix + ", lower(status) asc, dueDate desc");
} else if (sortKey.equals(SORT_DATE)) {
query.setOrder("dueDate " + sortPostfix +
", lower(status) asc, lower(pageTitle) asc");
query.setOrder("dueDate " + sortPostfix + ", lower(status) asc, lower(pageTitle) asc");
} else if (sortKey.equals(SORT_USER)) {
query.setOrder("lockingUserID " + sortPostfix +
", lower(status) asc, dueDate desc " +
", lower(pageTitle) asc");
query.setOrder("lockingUserID " + sortPostfix + ", lower(status) asc, dueDate desc "
+ ", lower(pageTitle) asc");
} else if (sortKey.equals(SORT_STATUS)) {
query.setOrder("lower(status) " + sortPostfix +
", dueDate desc " +
", lower(pageTitle) asc");
query.setOrder("lower(status) " + sortPostfix + ", dueDate desc " + ", lower(pageTitle) asc");
} else if (sortKey.equals(SORT_ACTION)) {
query.setOrder("taskType " + sortPostfix +
", lower(status) asc, dueDate desc " +
", lower(pageTitle) asc"
);
query.setOrder("taskType " + sortPostfix + ", lower(status) asc, dueDate desc "
+ ", lower(pageTitle) asc");
} else if (sortKey.equals(SORT_WORKFLOW)) {
query.setOrder("processLabel " + sortPostfix +
", lower(status) asc, dueDate desc " +
", lower(pageTitle) asc"
);
query.setOrder("processLabel " + sortPostfix + ", lower(status) asc, dueDate desc "
+ ", lower(pageTitle) asc");
}
HashMap sections = new HashMap();
@ -628,8 +616,7 @@ public class TasksPanel extends CMSContainer {
// m_actionLabel.generateXML(state, content);
String[][] sortableHeaders =
{{SORT_TITLE, "cms.ui.workflow.task.item_title"},
String[][] sortableHeaders = {{SORT_TITLE, "cms.ui.workflow.task.item_title"},
{SORT_ACTION, "cms.ui.action"},
{SORT_DATE, "cms.ui.tasks_due_date"},
{SORT_STATUS, "cms.ui.tasks_status_no_colon"},
@ -644,7 +631,7 @@ public class TasksPanel extends CMSContainer {
state.setControlEvent(this, SORT_UP, header);
}
SimpleContainer container = new SimpleContainer();
container.add(new Label(GlobalizationUtil.globalize(labelKey)));
container.add(new Label((String)GlobalizationUtil.globalize(labelKey).localize()));
if (header.equals(sortKey)) {
String imageURLStub = null;
if (SORT_UP.equals(sortDirection)) {
@ -664,7 +651,6 @@ public class TasksPanel extends CMSContainer {
}
}
@Override
public void respond(PageState state) throws ServletException {
String key = state.getControlEventName();
@ -715,10 +701,10 @@ public class TasksPanel extends CMSContainer {
throw new ServletException("Unknown control event: " + key);
}
}
}
private static Filter getTaskFilter(CMSTaskType taskType
, Party party, FilterFactory factory) {
private static Filter getTaskFilter(CMSTaskType taskType, Party party, FilterFactory factory) {
PrivilegeDescriptor privilege;
String queryName;
String queryType;
@ -727,5 +713,5 @@ public class TasksPanel extends CMSContainer {
return PermissionService.getFilterQuery(factory, "itemID", privilege, partyOID);
}
}
}

View File

@ -32,8 +32,10 @@ import com.arsdigita.globalization.GlobalizedMessage;
public class GlobalizationUtil {
/** */
// public static String s_bundleName =
// "com.arsdigita.cms.util.CMSResourceBundle";
public static String s_bundleName =
"com.arsdigita.cms.util.CMSResourceBundle";
"com.arsdigita.cms.CMSResources";
public static GlobalizedMessage globalize(String key) {
return new GlobalizedMessage(key, getBundleName());

View File

@ -44,8 +44,7 @@ import org.apache.log4j.Logger;
*/
public class GlobalizedMessage {
private static final Logger s_cat =
Logger.getLogger(GlobalizedMessage.class.getName());
private static final Logger LOGGER = Logger.getLogger(GlobalizedMessage.class.getName());
private String m_key = "";
private String m_bundleName = "";
private Object[] m_args = null;
@ -60,7 +59,7 @@ public class GlobalizedMessage {
*
* @param key The key to use to look up a message in the ResourceBundle.
*/
public GlobalizedMessage(String key) {
public GlobalizedMessage(final String key) {
setKey(key);
setBundleName();
}
@ -74,7 +73,7 @@ public class GlobalizedMessage {
* @param key The key to use to look up a message in the ResourceBundle.
* @param bundleName The base name of the target ResourceBundle.
*/
public GlobalizedMessage(String key, String bundleName) {
public GlobalizedMessage(final String key, final String bundleName) {
setKey(key);
setBundleName(bundleName);
}
@ -92,7 +91,7 @@ public class GlobalizedMessage {
* @param args An Object[] of arguments to interpolate into the retrieved
* message.
*/
public GlobalizedMessage(String key, Object[] args) {
public GlobalizedMessage(final String key, final Object[] args) {
this(key);
setArgs(args);
}
@ -109,7 +108,7 @@ public class GlobalizedMessage {
* @param args An Object[] of arguments to interpolate into the retrieved
* message.
*/
public GlobalizedMessage(String key, String bundleName, Object[] args) {
public GlobalizedMessage(final String key, final String bundleName, final Object[] args) {
this(key, bundleName);
setArgs(args);
}
@ -129,7 +128,7 @@ public class GlobalizedMessage {
*
* @param key
*/
private void setKey(String key) {
private void setKey(final String key) {
if (key == null || key.length() == 0) {
throw new IllegalArgumentException("key cannot be empty.");
}
@ -146,7 +145,7 @@ public class GlobalizedMessage {
setBundleName("com.arsdigita.dummy.DummyResources");
}
private void setBundleName(String bundleName) {
private void setBundleName(final String bundleName) {
if (bundleName == null || bundleName.length() == 0) {
throw new IllegalArgumentException("bundleName cannot be empty.");
}
@ -154,7 +153,7 @@ public class GlobalizedMessage {
m_bundleName = bundleName;
}
private void setArgs(Object[] args) {
private void setArgs(final Object[] args) {
m_args = args;
}
@ -192,7 +191,7 @@ public class GlobalizedMessage {
* java.text.MessageFormat class.
* </p>
*
* @param req The current running request.
* @param request The current running request.
*
* @return Object Represents the localized version of this
* message. The reason this method returns an Object and
@ -201,7 +200,7 @@ public class GlobalizedMessage {
* bites. Maybe this class should have been called
* GlobalizedObject?
*/
public Object localize(HttpServletRequest request) {
public Object localize(final HttpServletRequest request) {
return localize(com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale());
}
@ -226,34 +225,54 @@ public class GlobalizedMessage {
* bites. Maybe this class should have been called
* GlobalizedObject?
*/
public Object localize(Locale locale) {
public Object localize(final Locale locale) {
Object message = getKey();
ResourceBundle rb = null;
ResourceBundle resourceBundle = null;
if (locale == null) {
throw new IllegalArgumentException("locale cannot be null.");
}
try {
rb = ResourceBundle.getBundle(getBundleName(), locale);
// jensp 2013-03-16:
// Previously, ResourceBundle#getBundle(String, Locale) was called here. That was causing problems under
// specific circumstances:
// - The browser of the user is set the english (britain), languge code en_GB
// - The system language of the server running CCM is set to german (de_DE).
// In this case, the ResourceBundle.getBundle method first tries to find a ResourceBundle for en_GB, than
// for en. Usally, both attempts will fail because the english labels are in the default bundle
// (no language code). The standard search algorithm of ResourceBundle#getBundle than falls back to the
// system language (the language of the SERVER), which is German is this case. Therefore the content center
// was shown with german texts...
// Luckily, there is a simple solution: The search algorithm is implemented in the inner class
// ResourceBundle.Control. There are also variants of the getBundle method which allow it to pass an
// custom implementation of ResouceBundle.Control. Also ResourceBundle.Control has a factory method which
// offers an implementation of ResourceBundle.Control which does not use the system language.
// Therefore, all what was to do was to change the call of getBundle here from
// ResourceBundle#getBundle(String, Locale) to ResourceBundle#getBundle(String, Locale, ResourceControl)
// with ResourceBundle.Control.getNoFallbackControl(List<String>).
resourceBundle = ResourceBundle.getBundle(
getBundleName(),
locale,
ResourceBundle.Control.getNoFallbackControl(ResourceBundle.Control.FORMAT_PROPERTIES));
} catch (MissingResourceException e) {
if (s_cat.isDebugEnabled()) {
s_cat.debug(
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"ResourceBundle " + getBundleName() + " was not found.");
}
}
try {
if (rb != null) {
message = rb.getObject(getKey());
} else {
if (s_cat.isDebugEnabled()) {
s_cat.debug("No ResourceBundle available");
if (resourceBundle == null) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("No ResourceBundle available");
}
} else {
message = resourceBundle.getObject(getKey());
}
} catch (MissingResourceException e2) {
if (s_cat.isDebugEnabled()) {
s_cat.debug(getKey() + " was not found in the ResourceBundle.");
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(getKey() + " was not found in the ResourceBundle.");
}
}
@ -282,7 +301,9 @@ public class GlobalizedMessage {
*
* @return The contents in String form for debugging.
*/
@Override
public String toString() {
return getBundleName() + "#" + getKey();
}
}