@@ -716,6 +716,22 @@ def set_title_description_tags(self, workspace_object: Any, translated: dict[str
716716 if workspace_object .tags :
717717 workspace_object .tags = [translated [x ] for x in workspace_object .tags ]
718718
719+ def _extract_dashboard_date_filter_titles (self , to_translate : set [str ], dashboard_content : dict ) -> None :
720+ """Extract date filter titles from dashboard content for translation.
721+
722+ Args:
723+ to_translate: Set to collect translatable strings
724+ dashboard_content: Dashboard content dictionary containing date filter configurations
725+ """
726+ # Extract implicit date filter title
727+ implicit_date_filter_title = dashboard_content .get ("dateFilterConfig" , {}).get ("filterName" )
728+ self .add_title_description (to_translate , implicit_date_filter_title , None )
729+
730+ # Extract explicit date filter titles
731+ for date_filter_config in dashboard_content .get ("dateFilterConfigs" , []):
732+ explicit_date_filter_title = date_filter_config .get ("config" , {}).get ("filterName" )
733+ self .add_title_description (to_translate , explicit_date_filter_title , None )
734+
719735 def get_texts_to_translate (
720736 self ,
721737 workspace : CatalogWorkspace ,
@@ -745,7 +761,6 @@ def get_texts_to_translate(
745761 if workspace_content .analytics :
746762 for metric in workspace_content .analytics .metrics or []:
747763 self .add_title_description (to_translate , metric .title , metric .description )
748- if workspace_content .analytics :
749764 for visualization in workspace_content .analytics .visualization_objects or []:
750765 self .add_title_description (to_translate , visualization .title , visualization .description )
751766 for bucket in visualization .content ["buckets" ]:
@@ -754,7 +769,8 @@ def get_texts_to_translate(
754769 to_translate .add (item ["measure" ]["alias" ])
755770 for dashboard in workspace_content .analytics .analytical_dashboards or []:
756771 self .add_title_description (to_translate , dashboard .title , dashboard .description )
757- # Hack: translate titles in free-form, which is not processed intentionally by this SDK
772+ # Extract date filter titles for translation
773+ self ._extract_dashboard_date_filter_titles (to_translate , dashboard .content )
758774 for section in dashboard .content ["layout" ]["sections" ]:
759775 for item in section ["items" ]:
760776 widget = item ["widget" ]
@@ -763,10 +779,20 @@ def get_texts_to_translate(
763779 self .add_title_description (to_translate , title , description )
764780 if widget .get ("type" ) == "richText" and "content" in widget :
765781 to_translate .add (widget ["content" ])
782+ # process visualizations within visualization switcher
783+ if widget .get ("type" ) == "visualizationSwitcher" :
784+ for visualization_spec in widget .get ("visualizations" , []):
785+ title = visualization_spec .get ("title" )
786+ description = visualization_spec .get ("description" )
787+ self .add_title_description (to_translate , title , description )
766788 if "header" in section :
767789 title = section ["header" ].get ("title" )
768790 description = section ["header" ].get ("description" )
769791 self .add_title_description (to_translate , title , description )
792+ for filter_context in workspace_content .analytics .filter_contexts or []:
793+ for filter_spec in filter_context .content .get ("filters" , []):
794+ attribute_filter_title = filter_spec .get ("attributeFilter" , {}).get ("title" )
795+ self .add_title_description (to_translate , attribute_filter_title , None )
770796
771797 # Translate texts, which have not been translated yet
772798 if already_translated :
0 commit comments