Skip to content

i18n: localize message extraction producing incorrect equiv-text values #39195

Closed

Description

@petebacondarwin

(See #38711 (comment) for original report)

Extraction of i18n messages from the following template HTML:

<ng-container i18n="Update @@update"> <b>{{value1}}:</b> current {{value2}} to new {{value3}} </ng-container>

Without ivy: (ctype attributes removed for clarity)

<source>
  <x id="START_BOLD_TEXT" equiv-text="&lt;b&gt;"/>
  <x id="INTERPOLATION" equiv-text="{{value1}}"/>:
  <x id="CLOSE_BOLD_TEXT" equiv-text="&lt;/b&gt;"/> current
  <x id="INTERPOLATION_1" equiv-text="{{value2}}"/> to new
  <x id="INTERPOLATION_2" equiv-text="{{value3}}"/>
</source>

With ivy:

<source>
  <x id="START_BOLD_TEXT" equiv-text="&lt;b&gt;{{value1}}"/>
  <x id="INTERPOLATION" equiv-text="{{value1}}"/>:
  <x id="CLOSE_BOLD_TEXT" equiv-text="&lt;/b&gt; "/> current
  <x id="INTERPOLATION_1" equiv-text="{value2}} "/> to new
  <x id="INTERPOLATION_2" equiv-text="{value3}} "/>
</source>

It seems that there is some offsetting going on, which is making the start and end points in the equiv-text appear in the wrong place. I'll need to debug into this but since these equiv-text attributes are primarily to aid the translator's job, it will not be high on my priority list. Hopefully I can take a look at it later next week or the week after.

Activity

  1. added
    area: i18nIssues related to localization and internationalization
    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
    on Oct 9, 2020
  2. modified the milestone: Backlog on Oct 9, 2020
  3. petebacondarwin commented on Oct 26, 2020

    @petebacondarwin
    ContributorAuthor

    OK, so I did some debugging and this issue is caused by us skipping "leading trivia characters" thanks to this 304a12f.

    The problem appears because the i18n message begins with a leading space, which is skipped when computing the source-span for the start of the i18n message. This appears to make the source-spans for the inner pieces out of sync.

  4. petebacondarwin commented on Oct 26, 2020

    @petebacondarwin
    ContributorAuthor

    Actually things are more complex than just that, although that is part of it...
    It seems that there are various places where we are mapping back and forth between source-spans and parsed content, which is causing some source-spans to get out of sync.
    I think this needs some considerable thought...

  5. added a commit that references this issue on Nov 5, 2020
    b8e9b3d
  6. added 2 commits that reference this issue on Nov 6, 2020
    18d2395
    c392654
  7. added a commit that references this issue on Nov 6, 2020
    2b684b7
  8. bougnat12 commented on Nov 16, 2020

    @bougnat12

    I made some tests with last Angular 11 and I always have bad translation:

        <unit id="MAD.confirmDeleteModalMsg">
          <notes>
            <note category="location">src/app/components/setup/zone/detail/zone-detail.component.html:14,16</note>
            <note category="location">src/app/components/setup/wall/panel-setup/panel-setup.component.html:56,58</note>
            <note category="location">src/app/components/setup/vc/setup-panel/vc-setup-panel.component.html:10,12</note>
            <note category="location">src/app/components/setup/ps/setup-panel/ps-setup-panel.component.html:7,9</note>
          </notes>
          <segment>
            <source> Confirm delete <ph id="0" equiv="INTERPOLATION" disp="e {{uiName"/>?
    </source>
          </segment>
        </unit>

    for the original text to translate:

    <mad-modal-confirm i18n="@@MAD.confirmDeleteModalMsg" i18n-title="@@psSetupPanel.modalConfirmTitle" title="Delete Power Supply" size="md" id="deletePowerSupplyButton" (closed)="deletePowerSupplyConfirm($event)">
      Confirm delete {{uiName}}?
    </mad-modal-confirm>

    I'm really disappointed because I like the new Angular 11 version but I cannot migrate my project with this show stopper.

    For me it's not corrected and I don't understand why this issue was closed.

  9. petebacondarwin commented on Nov 16, 2020

    @petebacondarwin
    ContributorAuthor
  10. angular-automatic-lock-bot commented on Dec 17, 2020

    @angular-automatic-lock-bot

    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.

  11. locked and limited conversation to collaborators on Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: i18nIssues related to localization and internationalizationstate: has PRtype: bug/fix

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions