Components: mat-tooltip i18n

Created on 27 Feb 2018  路  7Comments  路  Source: angular/components

Bug, feature request, or proposal:

feature

What is the expected behavior?

MatTooltip should be able to show title from title attribute

What is the current behavior?

Only specify your own value

What are the steps to reproduce?

Providing a StackBlitz reproduction is the best way to share your issue.

StackBlitz starter: https://goo.gl/wwnhMV

What is the use-case or motivation for changing an existing behavior?

To need for i18n

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Is there anything else we should know?

Most helpful comment

Having the title attribute set will cause the browser tooltip to be shown. Passing a translated string should be handled by you.
You can do something like this

<span class="cdk-visually-hidden" #translatedTooltipMessage i18n="@@myTranslation">Will be translated</span>
...
<button [matTooltip]="translatedTooltipMessage.innerHTML">I have a translated tooltip</button>

All 7 comments

Having the title attribute set will cause the browser tooltip to be shown. Passing a translated string should be handled by you.
You can do something like this

<span class="cdk-visually-hidden" #translatedTooltipMessage i18n="@@myTranslation">Will be translated</span>
...
<button [matTooltip]="translatedTooltipMessage.innerHTML">I have a translated tooltip</button>

@msc117 Wow, it's a nice trick, but will be a cool having this method inside directive.

I haven't tried something like this before, but would this work?

<button i18n-matTooltip matTooltip="To be translated"></button>

Maybe i trying wrong, but string above doesn't work

Closing since we don't want to overload the title attribute and change default behavior of it

the i18n-matTooltip works well

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings