i18n icon indicating copy to clipboard operation
i18n copied to clipboard

Issue with RTL formatted language mixed with Latin words

Open happpyface opened this issue 2 years ago • 3 comments

There is a problem that I'm not sure it is related to Grammy or not. When using RTL language text (like Persian) that has LTR words within the Latin word get reversed. example

# fa.ftl
start = سلام { $name }! چطور می‌تونم کمکت کنم؟ 

The above sentence in English is "Hello { $name}! how can i help you?"

if name is Parsa (which is loaded from ctx.from.first_name) the result must be like below: سلام Parsa! چطور می‌تونم کمکت کنم؟ but the the result will be like this: سلام asraP! چطور می‌تونم کمکت کنم؟

I tried the Fluent playground to check if it's related to Fluent but it's not! check the link below: https://projectfluent.org/play/?id=2b91a538f800639b728f09d8853889e6

happpyface avatar Aug 29 '23 11:08 happpyface

Is its result really that or is it just your client rendering it that way?

rojvv avatar Aug 29 '23 11:08 rojvv

Maybe this will help. the second reply is displayed correctly in telegram.

bot.command('test', async ctx => {
  await ctx.reply(ctx.t('start', { name: 'Parsa' }))
  await ctx.reply('سلام Parsa! چطور می‌تونم کمکت کنم؟')
})

image

happpyface avatar Aug 29 '23 11:08 happpyface

Do you have useIsolating set to false in the i18n/fluent configuration? It is recommended to be enabled for RTL languages. That should be why you're having this issue.

See for more information: https://github.com/projectfluent/fluent.js/wiki/Unicode-Isolation

dcdunkan avatar Dec 19 '23 07:12 dcdunkan

Closing due to inactivity. Feel free to re-open if the issue still persists.

dcdunkan avatar Jul 18 '24 14:07 dcdunkan