Uniswap / interface

🦄 Open source interfaces for the Uniswap protocol
https://app.uniswap.org
GNU General Public License v3.0
4.88k stars 4.96k forks source link

crowdin auto translations do not consider JSX substitutions as tokens #2421

Open moodysalem opened 2 years ago

moodysalem commented 2 years ago

Bug Description When you use the Trans macro and include JSX components, e.g.:

import {Trans} from '@lingui/macro';

function MyComponent() {
  return <Trans>Hello <UserName/></Trans>;
}

The source string gets extracted and uploaded to Crowdin correctly as

Hello <0/>

However, the auto translation by Google Translate that we have set up in Crowdin does not recognize JSX tags as substitutions, and will for certain languages mess with the <0/> tag, e.g. for Arabic:

image

As a result, the automatic translation uploads a bunch of broken translations to the repository

image

Expected Behavior

The JSX substitution tokens are not modified by Crowdin

Additional Context

Crowdin's translation service has the same problem

I don't think substitution tokens that use the format {0}, {1}, etc. are affected

justindomingue commented 2 years ago

Could we use a render function for these?

https://lingui.js.org/ref/react.html#local-configuration

zzmp commented 2 years ago

I don't think a render function would work, because the placement of the component within the rendered translation may change depending on the language.