[ 
https://issues.apache.org/jira/browse/CAUSEWAY-4003?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andi Huber resolved CAUSEWAY-4003.
----------------------------------
    Resolution: Resolved

> [Wicket Viewer] Support for TitleColumn Header Translation
> ----------------------------------------------------------
>
>                 Key: CAUSEWAY-4003
>                 URL: https://issues.apache.org/jira/browse/CAUSEWAY-4003
>             Project: Causeway
>          Issue Type: Improvement
>          Components: Viewer Wicket
>    Affects Versions: 4.0.0-M1
>            Reporter: Miklós Győrfi
>            Assignee: Andi Huber
>            Priority: Minor
>             Fix For: 3.7.0, 4.0.0
>
>
> In the Apache Causeway Wicket Viewer component, the {{TitleColumn}} (used to 
> display the first/primary title column in parented and standalone collections 
> inside {{{}CollectionContentsAsAjaxTablePanel, etc.{}}}) hardcodes the column 
> headers as English text strings ("Object" and "Related Object").
> Because this is evaluated via a static helper method during constructor 
> invocation, it bypasses the framework's translation mechanisms, making it 
> impossible to localize these headers via standard {{translations.po}} files.
> *Affected Class:*
> {{org.apache.causeway.viewer.wicket.ui.components.collection.present.ajaxtable.columns.TitleColumn}}
> *Current problematic code snippet:*
>  
> {code:java}
> private static String columnName(
>         final @Nullable Variant variant,
>         final int maxTitleLength) {
>     if(maxTitleLength == 0) {
>         return "";
>     }
>     return (variant.isParented() ? "Related ":"") + "Object"; // <-- 
> Hardcoded English Strings
> }
> {code}
>  
> *Proposed Solution / Fix:*
> The {{columnName}} method should dynamically resolve the text using 
> Causeway's {{TranslationService}} fetched from the {{MetaModelContext}} to 
> allow proper localization.
> {code:java}
> private static String columnName(
>             final @Nullable Variant variant,
>             final int maxTitleLength) {
>         if(maxTitleLength == 0) {
>             return "";
>         }
>         String defaultLabel = "Object";
>         String contextClass = TitleColumn.class.getName();
>         var mmc = MetaModelContext.instanceNullable();
>         if (mmc != null) {
>             TranslationService translationService = 
> mmc.getTranslationService();
>             if (translationService != null) {
>                 var translationContext = 
> TranslationContext.named(contextClass);
>                 if (variant != null && variant.isParented()) {
>                     return translationService.translate(translationContext, 
> "Related Object");
>                 } else {
>                     return translationService.translate(translationContext, 
> "Object");
>                 }
>             }
>         }
>         return (variant != null && variant.isParented() ? "Related " : "") + 
> defaultLabel;    
>     }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to