I have gotten the ICU approach working, but I've come across another problem, I would like to have a hover title on my enum. Do you have any idea how to accomplish that? I've tried everything I could think of.
I thought that the first approach is not suitable for const enum, and since our company prefers using const enums I would rather not change that. Do you know any other way? If not, I will use the first approach anyway.
I have gotten the ICU approach working, but I've come across another problem, I would like to have a hover title on my enum. Do you have any idea how to accomplish that? I've tried everything I could think of.
Right, it might cause duplication in ICU approach. I'd go with first solution then.
Notes:
<ng-container>
anymore withtitle
attribute. I went with<span>
i18n-title
to translate attributeIvy update
If you use Ivy (and the best Angular 11.2+), there is new package
@angular/localize
, that can translate strings in TypeScript.So you could have re-usable function for providing messages:
Wow, thanks for the really quick reply!
I thought that the first approach is not suitable for const enum, and since our company prefers using const enums I would rather not change that. Do you know any other way? If not, I will use the first approach anyway.
We don't use Ivy unfortunately.
Yep, it has to be regular enum.
I also maintain practice to keep const enum, but they do not fit in every use case. Overhead is slightly bigger but not crazy
Ok I will change it to a regular enum. Thank you for your help!