Roman-Lo / vscode-ng-i18n-editor

An editor for angular generated xliff translation file.
MIT License
7 stars 3 forks source link

Editing interpolated values #21

Open damir-dezeljin opened 3 years ago

damir-dezeljin commented 3 years ago

First let me tell you the tool is great - it is a big improvement over editing raw .xlf files.

I'm facing an issue with the tool handling interpolated values. Please find below two snippets from my templates:

  1. Simple one:
    <span i18n="@@menu.profile.label"> Profile ({{username$ | async}})</span>
  2. A more complex one:
    <li i18n="@@userInfo.termsAndConditionsStatus">
      T&C status:
      <span *ngIf="isTacLoaded === false || userTacStatus === null; then tacDataEmpty else tacDataLoaded"></span>
      <ng-template #tacDataEmpty><code>&lt; No data available &gt;</code></ng-template>
      <ng-template #tacDataLoaded>
        <code *ngIf="userTacStatus.status === 'CONFIRMED'; then tacAccepted else tacRejected"></code>
        <ng-template #tacAccepted><code>ACCEPTED</code></ng-template>
        <ng-template #tacRejected><code>REVOKED</code></ng-template>
        (<code>{{ userTacStatus.created | date:'dd.MMM.yyyy @ HH:mm' }}</code>)
        <button color="primary" mat-raised-button matTooltip="Display terms" matTooltipPosition="above"
          class="small-revoke-button" (click)="onShowTac()">Display T&C</button>
        <button color="warn" mat-raised-button matTooltip="Revoke terms" matTooltipPosition="above"
          class="small-revoke-button" (click)="onRevokeTac()">Revoke</button>
      </ng-template>
    </li>

Here is a list of issues I'm facing:

  1. When a new interpolated value appears in source, there is no way to create / copy it to the target. Furthermore, if I try editing target translation for such a term, the tool hangs and I have to kill VS Code. I found a dirty work-around -- when this happens and I see an empty value in the I18N tool, I go back to the raw .xlf and copy/paste the value from the source .xlf to the target one, creating a <target>...</target> tag as a copy of the <source>...</source> one. This is super ugly and annoying, it would be already much better if there would be a button in the I18N tool for copying a term from the source language to the target one.
  2. The tool displays just #INTERPOLATION for such occurrences. The issue here is I don't really know what is in there
tsol commented 1 year ago

For future people trying to find an answer how to write INTERPOLATION placeholders in this editor - use space + hashtag before placeholder name. For example: If the phrase includes placeholder with name "userId" - in translation write "some text #userId".

I really wish this information was in README.