-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Open
Labels
area: i18nIssues related to localization and internationalizationIssues related to localization and internationalization
Milestone
Description
Which @angular/* package(s) are relevant/related to the feature request?
compiler, localize
Description
example:
<span> {{ nikename ?? 'ano' }} </span>
for now to support i18n, I should rewrite those code:
<span> {{ nickname ?? $$ANO }} </span>
class MyComponent {
readonly $$ANO = $localiza`:@@ANO:ano`;
}or like:
<span>
<ng-container *ngIf="nickname;else Str">{{nickname}}</ng-container>
<ng-template #Str><ng-container i18n="@@ANO">ano</ng-container></ng-template>
<span>
Proposed solution
<span> {{ nikename ?? $localiza(':@@ANO:ano') }} </span>
after read the source code. I think inject an function for template is better choose then pipe.
those code will compile to on consts:
$localiza.trans[":@@ANO:ano"] = $localiza`:@@ANO:ano`Tips
$localizeonly support string literal.eg:
$localize(str_var)is no support, suppose use variable, why notstr_var = $localize`text`$localizeonly support one argument.suppose transform code:
$localize(':@@MY_INTRO:my name is ', username, ', I\'m ', age ,' years old.')
to
$localize`:@@MY_INTRO:my name is \${name}, I'm ${age} years old.`;
consider using
htmlwould get better readability and maintainability:<ng-container i18n="@@MY_INTRO"> my name is {{name}}, I'm {{age}} years old. </ng-container>
Alternatives considered
noop
For now. I'm trying to make those code work in my project by hacking the source code. I hope someone could give me better suggest.
Relational link
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: i18nIssues related to localization and internationalizationIssues related to localization and internationalization