* Weitere Verbesserungen an den sprachunabhängigen Content Items
* Selectboxen zur Auswahl der Sprache und die Anzeige der Sprachen im Tab Sprachen ist nun lokalisiert mittels java.util.Locale git-svn-id: https://svn.libreccm.org/ccm/trunk@1200 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
c1aeb0f822
commit
eabd0ec620
|
|
@ -34,7 +34,6 @@ import com.arsdigita.kernel.permissions.PermissionService;
|
||||||
import com.arsdigita.persistence.DataAssociation;
|
import com.arsdigita.persistence.DataAssociation;
|
||||||
import com.arsdigita.persistence.DataAssociationCursor;
|
import com.arsdigita.persistence.DataAssociationCursor;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.Filter;
|
|
||||||
import com.arsdigita.persistence.FilterFactory;
|
import com.arsdigita.persistence.FilterFactory;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.persistence.metadata.Property;
|
import com.arsdigita.persistence.metadata.Property;
|
||||||
|
|
@ -66,6 +65,7 @@ public class ContentBundle extends ContentItem {
|
||||||
private static DomainObjectObserver s_instancesObserver =
|
private static DomainObjectObserver s_instancesObserver =
|
||||||
new AbstractDomainObjectObserver() {
|
new AbstractDomainObjectObserver() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void add(DomainObject dom, String name,
|
public void add(DomainObject dom, String name,
|
||||||
DataObject dobj) {
|
DataObject dobj) {
|
||||||
if (INSTANCES.equals(name)) {
|
if (INSTANCES.equals(name)) {
|
||||||
|
|
@ -97,6 +97,7 @@ public class ContentBundle extends ContentItem {
|
||||||
/**
|
/**
|
||||||
* Returns the data object type for this bundle.
|
* Returns the data object type for this bundle.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getBaseDataObjectType() {
|
public String getBaseDataObjectType() {
|
||||||
return BASE_DATA_OBJECT_TYPE;
|
return BASE_DATA_OBJECT_TYPE;
|
||||||
}
|
}
|
||||||
|
|
@ -159,6 +160,7 @@ public class ContentBundle extends ContentItem {
|
||||||
super(type);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected ContentItem makeCopy() {
|
protected ContentItem makeCopy() {
|
||||||
final ContentBundle newItem = (ContentBundle) super.makeCopy();
|
final ContentBundle newItem = (ContentBundle) super.makeCopy();
|
||||||
|
|
||||||
|
|
@ -378,8 +380,6 @@ public class ContentBundle extends ContentItem {
|
||||||
language + " is not an ISO639 language code");
|
language + " is not an ISO639 language code");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean retVal = false;
|
|
||||||
|
|
||||||
final DataAssociationCursor instances = instances();
|
final DataAssociationCursor instances = instances();
|
||||||
|
|
||||||
// If allowLanguageIndependent == false (default case), only search
|
// If allowLanguageIndependent == false (default case), only search
|
||||||
|
|
@ -586,6 +586,7 @@ public class ContentBundle extends ContentItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from item that bundle overrides
|
// Methods from item that bundle overrides
|
||||||
|
@Override
|
||||||
protected void beforeSave() {
|
protected void beforeSave() {
|
||||||
super.beforeSave();
|
super.beforeSave();
|
||||||
|
|
||||||
|
|
@ -598,25 +599,30 @@ public class ContentBundle extends ContentItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected boolean canPublishToFS() {
|
protected boolean canPublishToFS() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void publishToFS() {
|
protected void publishToFS() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ContentItem publish(final LifecycleDefinition definition,
|
public ContentItem publish(final LifecycleDefinition definition,
|
||||||
final Date start) {
|
final Date start) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Lifecycle getLifecycle() {
|
public Lifecycle getLifecycle() {
|
||||||
// Bundles do not have lifecycles.
|
// Bundles do not have lifecycles.
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setLifecycle(final Lifecycle lifecycle) {
|
public void setLifecycle(final Lifecycle lifecycle) {
|
||||||
// I'd like to do the following, but VersionCopier calls
|
// I'd like to do the following, but VersionCopier calls
|
||||||
// setLifecycle.
|
// setLifecycle.
|
||||||
|
|
@ -635,6 +641,7 @@ public class ContentBundle extends ContentItem {
|
||||||
* that regular metadata-driven methods should be used
|
* that regular metadata-driven methods should be used
|
||||||
* to copy the property.
|
* to copy the property.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean copyProperty(final CustomCopy source,
|
public boolean copyProperty(final CustomCopy source,
|
||||||
final Property property,
|
final Property property,
|
||||||
final ItemCopier copier) {
|
final ItemCopier copier) {
|
||||||
|
|
@ -649,6 +656,7 @@ public class ContentBundle extends ContentItem {
|
||||||
return super.copyProperty(source, property, copier);
|
return super.copyProperty(source, property, copier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean copyServices(final ContentItem source) {
|
public boolean copyServices(final ContentItem source) {
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Copying services on bundle " + getName() + " "
|
s_log.debug("Copying services on bundle " + getName() + " "
|
||||||
|
|
@ -667,6 +675,7 @@ public class ContentBundle extends ContentItem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void initialize() {
|
protected void initialize() {
|
||||||
super.initialize();
|
super.initialize();
|
||||||
addObserver(s_instancesObserver);
|
addObserver(s_instancesObserver);
|
||||||
|
|
@ -674,6 +683,7 @@ public class ContentBundle extends ContentItem {
|
||||||
m_wasNew = isNew();
|
m_wasNew = isNew();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void afterSave() {
|
protected void afterSave() {
|
||||||
if (m_wasNew) {
|
if (m_wasNew) {
|
||||||
getPrimaryInstance().setContentSection(getContentSection());
|
getPrimaryInstance().setContentSection(getContentSection());
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ import com.arsdigita.util.LockableImpl;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a list of all language instances of an item.
|
* Displays a list of all language instances of an item.
|
||||||
*
|
*
|
||||||
|
|
@ -76,7 +75,7 @@ public class ItemLanguagesTable extends DataTable {
|
||||||
* Builds the query for all the language instances in the current Bundle
|
* Builds the query for all the language instances in the current Bundle
|
||||||
*/
|
*/
|
||||||
private static class LanguagesBuilder extends LockableImpl
|
private static class LanguagesBuilder extends LockableImpl
|
||||||
implements DataQueryBuilder {
|
implements DataQueryBuilder {
|
||||||
|
|
||||||
ItemSelectionModel m_model;
|
ItemSelectionModel m_model;
|
||||||
|
|
||||||
|
|
@ -86,7 +85,7 @@ public class ItemLanguagesTable extends DataTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataQuery makeDataQuery(DataTable t, PageState s) {
|
public DataQuery makeDataQuery(DataTable t, PageState s) {
|
||||||
ContentPage multiLingual = (ContentPage)m_model.getSelectedObject(s);
|
ContentPage multiLingual = (ContentPage) m_model.getSelectedObject(s);
|
||||||
DataQuery q = SessionManager.getSession().retrieveQuery("com.arsdigita.cms.getBundledItems");
|
DataQuery q = SessionManager.getSession().retrieveQuery("com.arsdigita.cms.getBundledItems");
|
||||||
q.setParameter("bundleID", multiLingual.getContentBundle().getID());
|
q.setParameter("bundleID", multiLingual.getContentBundle().getID());
|
||||||
return q;
|
return q;
|
||||||
|
|
@ -101,14 +100,13 @@ public class ItemLanguagesTable extends DataTable {
|
||||||
* Renders the full language name.
|
* Renders the full language name.
|
||||||
*/
|
*/
|
||||||
private static class LanguageRenderer implements TableCellRenderer {
|
private static class LanguageRenderer implements TableCellRenderer {
|
||||||
|
|
||||||
public Component getComponent(Table table, PageState state, Object value,
|
public Component getComponent(Table table, PageState state, Object value,
|
||||||
boolean isSelected, Object key,
|
boolean isSelected, Object key,
|
||||||
int row, int column) {
|
int row, int column) {
|
||||||
BigDecimal id = (BigDecimal) key;
|
BigDecimal id = (BigDecimal) key;
|
||||||
String target = ContentItemPage.getRelativeItemURL
|
String target = ContentItemPage.getRelativeItemURL(id, ContentItemPage.AUTHORING_TAB);
|
||||||
(id, ContentItemPage.AUTHORING_TAB);
|
return new Link(new Label(LanguageUtil.getLangFull((String) value)), target);
|
||||||
GlobalizedMessage fullName = LanguageUtil.globalize((String)value);
|
|
||||||
return new Link(new Label(fullName), target);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,6 +114,7 @@ public class ItemLanguagesTable extends DataTable {
|
||||||
* Delete language instance action link.
|
* Delete language instance action link.
|
||||||
*/
|
*/
|
||||||
private static class ActionCellRenderer implements TableCellRenderer {
|
private static class ActionCellRenderer implements TableCellRenderer {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(ActionCellRenderer.class);
|
private static final Logger logger = Logger.getLogger(ActionCellRenderer.class);
|
||||||
private static Label s_noAction;
|
private static Label s_noAction;
|
||||||
private static Label s_primary;
|
private static Label s_primary;
|
||||||
|
|
@ -131,15 +130,15 @@ public class ItemLanguagesTable extends DataTable {
|
||||||
s_link.setConfirmation("Permanently delete this item?"); // XXX G11N ?
|
s_link.setConfirmation("Permanently delete this item?"); // XXX G11N ?
|
||||||
logger.debug("Static initalizer finished.");
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemSelectionModel m_model;
|
private ItemSelectionModel m_model;
|
||||||
|
|
||||||
public ActionCellRenderer(ItemSelectionModel model) {
|
public ActionCellRenderer(ItemSelectionModel model) {
|
||||||
m_model = model;
|
m_model = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getComponent(Table table, PageState state, Object value,
|
public Component getComponent(Table table, PageState state, Object value,
|
||||||
boolean isSelected, Object key,
|
boolean isSelected, Object key,
|
||||||
int row, int column) {
|
int row, int column) {
|
||||||
if (m_model.getSelectedKey(state).equals(key)) {
|
if (m_model.getSelectedKey(state).equals(key)) {
|
||||||
return s_noAction;
|
return s_noAction;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -148,8 +147,8 @@ public class ItemLanguagesTable extends DataTable {
|
||||||
OID oid = new OID(ContentPage.BASE_DATA_OBJECT_TYPE, id);
|
OID oid = new OID(ContentPage.BASE_DATA_OBJECT_TYPE, id);
|
||||||
try {
|
try {
|
||||||
ContentPage item = (ContentPage) DomainObjectFactory.newInstance(oid);
|
ContentPage item = (ContentPage) DomainObjectFactory.newInstance(oid);
|
||||||
if ( item.getLanguage().equals(
|
if (item.getLanguage().equals(
|
||||||
item.getContentBundle().getDefaultLanguage())) {
|
item.getContentBundle().getDefaultLanguage())) {
|
||||||
return s_primary;
|
return s_primary;
|
||||||
}
|
}
|
||||||
} catch (com.arsdigita.domain.DataObjectNotFoundException ex) {
|
} catch (com.arsdigita.domain.DataObjectNotFoundException ex) {
|
||||||
|
|
@ -162,10 +161,11 @@ public class ItemLanguagesTable extends DataTable {
|
||||||
|
|
||||||
// delete one language instance
|
// delete one language instance
|
||||||
private class InstanceDeleter extends TableActionAdapter {
|
private class InstanceDeleter extends TableActionAdapter {
|
||||||
|
|
||||||
public void cellSelected(TableActionEvent e) {
|
public void cellSelected(TableActionEvent e) {
|
||||||
int col = e.getColumn().intValue();
|
int col = e.getColumn().intValue();
|
||||||
|
|
||||||
if ( m_deleteColumn != getColumn(col) ) {
|
if (m_deleteColumn != getColumn(col)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -184,5 +184,4 @@ public class ItemLanguagesTable extends DataTable {
|
||||||
((Table) e.getSource()).clearSelection(s);
|
((Table) e.getSource()).clearSelection(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,11 @@ import com.arsdigita.util.Pair;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods for dealing with the multilingual items.
|
* Utility methods for dealing with the multilingual items.
|
||||||
*
|
*
|
||||||
|
|
@ -43,39 +43,37 @@ import java.util.StringTokenizer;
|
||||||
public class LanguageUtil {
|
public class LanguageUtil {
|
||||||
|
|
||||||
private static org.apache.log4j.Logger s_log =
|
private static org.apache.log4j.Logger s_log =
|
||||||
org.apache.log4j.Logger.getLogger(LanguageUtil.class);
|
org.apache.log4j.Logger.getLogger(LanguageUtil.class);
|
||||||
|
|
||||||
private static String s_languages = null;
|
private static String s_languages = null;
|
||||||
private static String[] s_languagesArray = null;
|
private static String[] s_languagesArray = null;
|
||||||
|
|
||||||
/** Mapping from the ISO639-1 2-letter codes to the ISO639-2 3-letter codes */
|
/** Mapping from the ISO639-1 2-letter codes to the ISO639-2 3-letter codes */
|
||||||
private static final String ISO639_2LA_3LA = "com.arsdigita.cms.util.iso639rev";
|
private static final String ISO639_2LA_3LA = "com.arsdigita.cms.util.iso639rev";
|
||||||
private static ResourceBundle s_lang3LA = ResourceBundle.getBundle(ISO639_2LA_3LA);
|
private static ResourceBundle s_lang3LA = ResourceBundle.getBundle(ISO639_2LA_3LA);
|
||||||
|
|
||||||
/** Mapping from the ISO639-1 2-letter codes to the full descriptive name */
|
/** Mapping from the ISO639-1 2-letter codes to the full descriptive name */
|
||||||
private static final String ISO639_2LA_FULL = "com.arsdigita.cms.util.iso639full";
|
private static final String ISO639_2LA_FULL = "com.arsdigita.cms.util.iso639full";
|
||||||
private static ResourceBundle s_langFull = ResourceBundle.getBundle(ISO639_2LA_FULL);
|
private static ResourceBundle s_langFull = ResourceBundle.getBundle(ISO639_2LA_FULL);
|
||||||
|
|
||||||
|
|
||||||
public static GlobalizedMessage globalize(String key) {
|
public static GlobalizedMessage globalize(String key) {
|
||||||
return new GlobalizedMessage(key, ISO639_2LA_FULL);
|
return new LanguageGlobalizedMessage(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Sets the supported languages, eliminates all spaces and trims
|
||||||
|
*
|
||||||
* @param comma separated list of langages initialized from initializer
|
* @param comma separated list of langages initialized from initializer
|
||||||
* at the server startup
|
* at the server startup
|
||||||
*/
|
*/
|
||||||
public static void setSupportedLanguages(String languages) {
|
public static void setSupportedLanguages(String languages) {
|
||||||
if(Kernel.getConfig().languageIndependentItems()) {
|
if (Kernel.getConfig().languageIndependentItems() && !languages.contains(GlobalizationHelper.LANG_INDEPENDENT)) {
|
||||||
s_languages = languages + "," + GlobalizationHelper.LANG_INDEPENDENT;
|
s_languages = languages.replace(" ", "").trim() + "," + GlobalizationHelper.LANG_INDEPENDENT;
|
||||||
} else {
|
} else {
|
||||||
s_languages = languages;
|
s_languages = languages.replace(" ", "").trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the comma separated list of all supported languages */
|
/** Get the comma separated list of all supported languages */
|
||||||
public static String getSupportedLanguages() {
|
public static String getSupportedLanguages() {
|
||||||
Assert.exists(s_languages , "supported languages not set");
|
Assert.exists(s_languages, "supported languages not set");
|
||||||
return s_languages;
|
return s_languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,10 +82,10 @@ public class LanguageUtil {
|
||||||
*/
|
*/
|
||||||
public static Collection getSupportedLanguages2LA() {
|
public static Collection getSupportedLanguages2LA() {
|
||||||
String allLanguages = getSupportedLanguages();
|
String allLanguages = getSupportedLanguages();
|
||||||
StringTokenizer tokenizer = new StringTokenizer(allLanguages , ",");
|
StringTokenizer tokenizer = new StringTokenizer(allLanguages, ",");
|
||||||
Collection langList = new LinkedList();
|
Collection langList = new LinkedList();
|
||||||
while (tokenizer.hasMoreElements()) {
|
while (tokenizer.hasMoreElements()) {
|
||||||
String language = tokenizer.nextToken().trim();
|
String language = tokenizer.nextToken();
|
||||||
langList.add(language);
|
langList.add(language);
|
||||||
}
|
}
|
||||||
return langList;
|
return langList;
|
||||||
|
|
@ -99,11 +97,11 @@ public class LanguageUtil {
|
||||||
*/
|
*/
|
||||||
public static Collection getSupportedLanguages3LA() {
|
public static Collection getSupportedLanguages3LA() {
|
||||||
String allLanguages = getSupportedLanguages();
|
String allLanguages = getSupportedLanguages();
|
||||||
StringTokenizer tokenizer = new StringTokenizer(allLanguages , ",");
|
StringTokenizer tokenizer = new StringTokenizer(allLanguages, ",");
|
||||||
Collection langList = new LinkedList();
|
Collection langList = new LinkedList();
|
||||||
while (tokenizer.hasMoreElements()) {
|
while (tokenizer.hasMoreElements()) {
|
||||||
String language = tokenizer.nextToken().trim();
|
String language = tokenizer.nextToken();
|
||||||
langList.add(new Pair(language , getLang3LA(language)));
|
langList.add(new Pair(language, getLang3LA(language)));
|
||||||
}
|
}
|
||||||
return langList;
|
return langList;
|
||||||
}
|
}
|
||||||
|
|
@ -114,11 +112,11 @@ public class LanguageUtil {
|
||||||
*/
|
*/
|
||||||
public static Collection getSupportedLanguagesFull() {
|
public static Collection getSupportedLanguagesFull() {
|
||||||
String allLanguages = getSupportedLanguages();
|
String allLanguages = getSupportedLanguages();
|
||||||
StringTokenizer tokenizer = new StringTokenizer(allLanguages , ",");
|
StringTokenizer tokenizer = new StringTokenizer(allLanguages, ",");
|
||||||
Collection langList = new LinkedList();
|
Collection langList = new LinkedList();
|
||||||
while (tokenizer.hasMoreElements()) {
|
while (tokenizer.hasMoreElements()) {
|
||||||
String language = tokenizer.nextToken().trim();
|
String language = tokenizer.nextToken();
|
||||||
langList.add(new Pair(language , getLangFull(language)));
|
langList.add(new Pair(language, getLangFull(language)));
|
||||||
}
|
}
|
||||||
return langList;
|
return langList;
|
||||||
}
|
}
|
||||||
|
|
@ -142,13 +140,21 @@ public class LanguageUtil {
|
||||||
* @return three letter code for the two letter code.
|
* @return three letter code for the two letter code.
|
||||||
* If the resource is not found then the key itself is returned.
|
* If the resource is not found then the key itself is returned.
|
||||||
*/
|
*/
|
||||||
public static String getLang3LA( String lang ) {
|
public static String getLang3LA(String lang) {
|
||||||
String threeLA;
|
String threeLA;
|
||||||
try {
|
try {
|
||||||
threeLA = s_lang3LA.getString(lang);
|
// Lookup 3-letter language code via java.util.Locale
|
||||||
} catch (MissingResourceException mexc) {
|
threeLA = (new Locale(lang)).getISO3Language();
|
||||||
s_log.warn("Three letter language code for key '"+lang+"' not found: "+mexc);
|
} catch (MissingResourceException mre) {
|
||||||
threeLA = lang.trim();
|
// If there is none
|
||||||
|
try {
|
||||||
|
// Lookup 3-letter code via ressource bundle
|
||||||
|
threeLA = s_lang3LA.getString(lang);
|
||||||
|
} catch (MissingResourceException mexc) {
|
||||||
|
// if there is still no match, log a warning and return the 2-letter code
|
||||||
|
s_log.warn("Three letter language code for key '" + lang + "' not found: " + mexc);
|
||||||
|
threeLA = lang;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return threeLA;
|
return threeLA;
|
||||||
}
|
}
|
||||||
|
|
@ -160,13 +166,20 @@ public class LanguageUtil {
|
||||||
* @return full language name for the given two letter code
|
* @return full language name for the given two letter code
|
||||||
* If the resource is not found then the key itself is returned.
|
* If the resource is not found then the key itself is returned.
|
||||||
*/
|
*/
|
||||||
public static String getLangFull( String lang ) {
|
public static String getLangFull(String lang) {
|
||||||
String fullName;
|
// Lookup language name via java.util.Locale
|
||||||
try{
|
String fullName = (new Locale(lang)).getDisplayLanguage(GlobalizationHelper.getNegotiatedLocale());
|
||||||
fullName = s_langFull.getString(lang);
|
|
||||||
} catch (MissingResourceException mexc) {
|
if(lang.equals(fullName)) {
|
||||||
s_log.warn( "Full language name for key '"+lang+"' not found "+mexc);
|
// If that fails
|
||||||
fullName = lang;
|
try {
|
||||||
|
// Lookup language name vie ressource bundle
|
||||||
|
fullName = s_langFull.getString(lang);
|
||||||
|
} catch (MissingResourceException mexc) {
|
||||||
|
// If there is still nomatch, log a warning and return 2-letter code
|
||||||
|
s_log.warn("Full language name for key '" + lang + "' not found " + mexc);
|
||||||
|
fullName = lang;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return fullName;
|
return fullName;
|
||||||
}
|
}
|
||||||
|
|
@ -176,29 +189,41 @@ public class LanguageUtil {
|
||||||
*/
|
*/
|
||||||
public static Collection convertTo3LA(Collection list) {
|
public static Collection convertTo3LA(Collection list) {
|
||||||
Collection conList = new LinkedList();
|
Collection conList = new LinkedList();
|
||||||
for (Iterator iter=list.iterator(); iter.hasNext(); ) {
|
for (Iterator iter = list.iterator(); iter.hasNext();) {
|
||||||
String lang2Code = (String) iter.next();
|
String lang2Code = (String) iter.next();
|
||||||
conList.add( new Pair( lang2Code , getLang3LA(lang2Code) ) );
|
conList.add(new Pair(lang2Code, getLang3LA(lang2Code)));
|
||||||
}
|
}
|
||||||
return conList;
|
return conList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection convertToFull(Collection list) {
|
public static Collection convertToFull(Collection list) {
|
||||||
Collection conList = new LinkedList();
|
Collection conList = new LinkedList();
|
||||||
for (Iterator iter=list.iterator(); iter.hasNext(); ) {
|
for (Iterator iter = list.iterator(); iter.hasNext();) {
|
||||||
String lang2Code = (String) iter.next();
|
String lang2Code = (String) iter.next();
|
||||||
conList.add( new Pair( lang2Code , getLangFull(lang2Code) ) );
|
conList.add(new Pair(lang2Code, getLangFull(lang2Code)));
|
||||||
}
|
}
|
||||||
return conList;
|
return conList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection convertToG11N(Collection list) {
|
public static Collection convertToG11N(Collection list) {
|
||||||
Collection conList = new LinkedList();
|
Collection conList = new LinkedList();
|
||||||
for (Iterator iter=list.iterator(); iter.hasNext(); ) {
|
for (Iterator iter = list.iterator(); iter.hasNext();) {
|
||||||
String lang2Code = (String) iter.next();
|
String lang2Code = (String) iter.next();
|
||||||
conList.add( new Pair( lang2Code , globalize(lang2Code) ) );
|
conList.add(new Pair(lang2Code, globalize(lang2Code)));
|
||||||
}
|
}
|
||||||
return conList;
|
return conList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special GlobalizedMessage for use with the LanguageUtil#globalize method
|
||||||
|
private static class LanguageGlobalizedMessage extends GlobalizedMessage {
|
||||||
|
|
||||||
|
public LanguageGlobalizedMessage(String key) {
|
||||||
|
super(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object localize(Locale locale) {
|
||||||
|
return LanguageUtil.getLangFull(this.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -371,10 +371,12 @@ public class MultipartHttpServletRequest implements HttpServletRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String convertToString( Object value ) throws IOException {
|
private String convertToString( Object value ) throws IOException {
|
||||||
if( value instanceof String ) return (String) value;
|
if( value instanceof String ) {
|
||||||
|
return (String) value;
|
||||||
|
}
|
||||||
|
|
||||||
if( value instanceof ByteArrayInputStream ) {
|
if( value instanceof ByteArrayInputStream ) {
|
||||||
StringBuffer output = new StringBuffer();
|
StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
InputStreamReader reader;
|
InputStreamReader reader;
|
||||||
try {
|
try {
|
||||||
|
|
@ -391,7 +393,9 @@ public class MultipartHttpServletRequest implements HttpServletRequest {
|
||||||
int read = bufSize;
|
int read = bufSize;
|
||||||
while( bufSize == read ) {
|
while( bufSize == read ) {
|
||||||
read = reader.read( buffer, 0, bufSize );
|
read = reader.read( buffer, 0, bufSize );
|
||||||
if( read > 0 ) output.append( buffer, 0, read );
|
if( read > 0 ) {
|
||||||
|
output.append( buffer, 0, read );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.toString();
|
return output.toString();
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.globalization;
|
package com.arsdigita.globalization;
|
||||||
|
|
||||||
import com.arsdigita.kernel.Kernel;
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
|
|
@ -178,7 +177,6 @@ public class GlobalizedMessage {
|
||||||
* GlobalizedObject?
|
* GlobalizedObject?
|
||||||
*/
|
*/
|
||||||
public Object localize() {
|
public Object localize() {
|
||||||
// return localize(Kernel.getContext().getLocale());
|
|
||||||
return localize(com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale());
|
return localize(com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,7 +202,6 @@ public class GlobalizedMessage {
|
||||||
* GlobalizedObject?
|
* GlobalizedObject?
|
||||||
*/
|
*/
|
||||||
public Object localize(HttpServletRequest request) {
|
public Object localize(HttpServletRequest request) {
|
||||||
// return localize(Kernel.getContext().getLocale());
|
|
||||||
return localize(com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale());
|
return localize(com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
package com.arsdigita.london.navigation.ui;
|
package com.arsdigita.london.navigation.ui;
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import java.util.logging.Level;
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue