11import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js" ;
22import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js" ;
33import property from "@ui5/webcomponents-base/dist/decorators/property.js" ;
4- import i18n from "@ui5/webcomponents-base/dist/decorators/i18n.js" ;
54import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js" ;
6- import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
75import { getIconData , getIconDataSync } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js" ;
6+ import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
87
98// Template
109import AvatarBadgeTemplate from "./AvatarBadgeTemplate.js" ;
1110
1211// Styles
1312import AvatarBadgeCss from "./generated/themes/AvatarBadge.css.js" ;
1413
15- import { AVATAR_TOOLTIP } from "./generated/i18n/i18n-defaults.js" ;
16-
1714import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js" ;
1815
1916const ICON_NOT_FOUND = "ICON_NOT_FOUND" ;
@@ -107,9 +104,6 @@ class AvatarBadge extends UI5Element {
107104 @property ( { noAttribute : true } )
108105 effectiveAccessibleName ?: string ;
109106
110- @i18n ( "@ui5/webcomponents" )
111- static i18nBundle : I18nBundle ;
112-
113107 async onBeforeRendering ( ) {
114108 const icon = this . icon ;
115109 if ( ! icon ) {
@@ -126,12 +120,17 @@ class AvatarBadge extends UI5Element {
126120 } else if ( this . accessibleName ) {
127121 // User-provided accessible name takes precedence
128122 this . effectiveAccessibleName = this . accessibleName ;
123+ } else if ( iconData && iconData !== ICON_NOT_FOUND && iconData . accData ) {
124+ // Use the icon's registered i18n label (e.g., message-error -> "Error")
125+ if ( iconData . packageName ) {
126+ const i18nBundle = await getI18nBundle ( iconData . packageName ) ;
127+ this . effectiveAccessibleName = i18nBundle . getText ( iconData . accData ) || undefined ;
128+ } else {
129+ this . effectiveAccessibleName = iconData . accData . defaultText || undefined ;
130+ }
129131 } else {
130132 // Derive from icon name (e.g., "edit" -> "Edit")
131- // If not possible, fall back to i18n "Avatar" text
132- this . effectiveAccessibleName = icon
133- ? icon . charAt ( 0 ) . toUpperCase ( ) + icon . slice ( 1 )
134- : AvatarBadge . i18nBundle . getText ( AVATAR_TOOLTIP ) ;
133+ this . effectiveAccessibleName = icon . charAt ( 0 ) . toUpperCase ( ) + icon . slice ( 1 ) ;
135134 }
136135 }
137136}
0 commit comments