js-lingui: [Pseudo Localization] Syntax tokens shouldn't be pseudo localized

Describe the bug

Pseudolocalization mutates syntax tokens, for example in the follow select syntax the key “screener” is mutated as well as the select keyword.

Error: Can't parse message. Please check correct syntax: "Ŷōũŕ ƥŕōvĩďēŕ śēńţ à {0, śēĺēćţ, śćŕēēńēŕ {ŵēĺĺńēśś àśśēśśmēńţ} other {{assessmentType}}} ƒōŕ ŷōũ ţō ţàķē. Ƥĺēàśē ţàķē à ƒēŵ mĩńũţēś ţō ćōmƥĺēţē ţĥĩś àśśēśśmēńţ ƀēƒōŕē ŷōũŕ ńēxţ àƥƥōĩńţmēńţ."

To Reproduce Steps to reproduce the behavior, possibly with minimal code sample, e.g:

import { Trans } from "@lingui/react"

export default function App() {
   return (
    <div>
      Your provider sent a{' '}
            <Select
              value={isScreenerAssessment ? 'screener' : 'other'}
              screener="wellness assessment"
              other={assessmentType}
            />{' '}
            for you to take. Please take a few minutes to complete this
            assessment before your next appointment.
    </div>
}

Expected behavior Syntax and tokens are unchanged, only actual language.

Additional context Add any other context about the problem here.

  • jsLingui version: 2.9.1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

Okay i fix #919 asap

Awesome! Thanks for the quick fix!

A final question: any idea when a new release would be drafted?

We like to release new version each Tuesday. So the next Tuesday will include this fix =)

@MartinCerny-awin #919 is merged feel free to improve select pseudolocaliaztion.

You can introduce this test:

  it("Select", () => {
    expect(
      pseudoLocalize(
        "{gender, select, male {He} female {She} other {<span>Other</span>}}"
      )
    ).toEqual(
      "{gender, select, male {Ĥē} female {Śĥē} other {<span>Ōţĥēŕ</span>}}"
    )
  })