microsoft / vscode-l10n

MIT License
66 stars 14 forks source link

How to keep '\u200b' in generated xlf file? #131

Closed Cosifne closed 1 year ago

Cosifne commented 1 year ago

We have links need translated like https://github.com/dotnet/vscode-csharp/blob/a62858ca0eaaf750d3aff17c87e52d4ca779891b/package.nls.json#L248 includes \u200b However, when I run generate-xlf, \u200b is not reserved in the xlf files. image image

This is causing the localization engine to remove \u200b from the link. https://github.com/dotnet/vscode-csharp/pull/6388/files Is there any way to keep the character

Cosifne commented 1 year ago

Tag @TylerLeonhardt to help

TylerLeonhardt commented 1 year ago

I just tried this and I can't repro:

package.nls.json:

{
    "generateOptionsSchema.symbolOptions.searchMicrosoftSymbolServer.description": {
        "message": "If 'true' the Microsoft Symbol server (https\u200b://msdl.microsoft.com\u200b/download/symbols) is added to the symbols search path. If unspecified, this option defaults to 'false'.",
        "comment": [
          "We use '\u200b' (unicode zero-length space character) to break VS Code's URL detection regex for URLs that are examples. Please do not translate or localized the URL.",
          "{Locked='(https\u200b://msdl.microsoft.com\u200b/download/symbols)'}"
        ]
    }
}

Command output:

>> npx @vscode/l10n-dev@latest generate-xlf ./package.nls.json -o foo.xlf
Searching for L10N JSON files...
Found 1 L10N JSON files. Generating XLF...
Wrote XLF file to: foo.xlf

Resulting XLF:

image

Raw XLF if you want to copy and verify yourself:

<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file original="package" source-language="en" datatype="plaintext"><body>
    <trans-unit id="generateOptionsSchema.symbolOptions.searchMicrosoftSymbolServer.description">
      <source xml:lang="en">If &apos;true&apos; the Microsoft Symbol server (https​://msdl.microsoft.com​/download/symbols) is added to the symbols search path. If unspecified, this option defaults to &apos;false&apos;.</source>
      <note>We use &apos;​&apos; (unicode zero-length space character) to break VS Code&apos;s URL detection regex for URLs that are examples. Please do not translate or localized the URL.
{Locked=&apos;(https​://msdl.microsoft.com​/download/symbols)&apos;}</note>
    </trans-unit>
  </body></file>
</xliff>

Are you able to repro this locally?

Cosifne commented 1 year ago

Ah I just checked the loc content looks like it is actually perserved. (Just Github doesn't show it in the PR) Close this issue. Thanks Tyler!