Translate enumerations with Angular i18n native module

Viewed 245

What is the best solution to translate enumerations in Angular application v12 using $localize?

Below an example of one of my enumeration:

export enum MyEnum {

        "Value 1",
    
        "Value 2",
    
        "Value 3"
}

The solutions that I found is to add $localize in the typescript enum file like:

export enum MyEnum {
        
            $localize `:myEnumeration:Value 1`,
        
            $localize `:myEnumeration:Value 2`,
        
            $localize `:myEnumeration:Value 3`
    }

It works fine and it will generate in the xlf file the labels to translate, but in a big application with many enumerations, the xlf file's size will be so so big.

Adding an angular component per enumeration is not also the best solution that I found in a big app.

So, is there a good way to translate enumerations using $localize with low code?

Thanks

0 Answers
Related