i18next / react-i18next

Internationalization for react done right. Using the i18next i18n ecosystem.
https://react.i18next.com
MIT License
9.21k stars 1.02k forks source link

Trans component not interpolating correctly for Arabic translations #1794

Closed AsuraKev closed 3 weeks ago

AsuraKev commented 3 weeks ago

Hi there,

I have the following component defined

By signing up my team members, I accept the company {t('teamRegistration.agreement.termsOfUse')} and acknowledge the {t('teamRegistration.agreement.privacyStatement')}

and the english translation in the json as

"sentence": "By signing up my team members, I accept the Fisher & Paykel Healthcare <1><0>terms and acknowledge the <3><0>privacy.",

Everything renders correctly for the Link tag. However when i try this out with Arabic text من خلال تسجيل أعضاء فريقي، فإنني أوافق على [شروط الاستخدام] الخاصة بشركة Fisher & Paykel Healthcare وأوافق على [بيان الخصوصية].

First issue I encountered was not able to put the interpolation expression in the text as the cursor jumps around and even i managed to push some in, it didnt render out correctly.

Can someone shed some light and show me example of actually apply Trans interpolation with arabic text?

thanks

adrai commented 3 weeks ago
<0> is for Trans component, not for t function: https://www.i18next.com/translation-function/interpolation
AsuraKev commented 3 weeks ago

Sorry yes using the Trans component I am unable to insert <></> placeholder in the Arabic text. Any idea how to get past this? Seems very tricky 😅

jamuhl commented 3 weeks ago

My problem...I have no idea what is incorrect on:

من خلال تسجيل أعضاء فريقي، فإنني أوافق على [شروط الاستخدام] الخاصة بشركة Fisher & Paykel Healthcare وأوافق على [بيان الخصوصية].

As I'm not able to read any rtl language

but might be somewhat a general tricky thing with bidi: https://stackoverflow.com/questions/28257257/right-to-left-order-of-different-directioned-spans

AsuraKev commented 3 weeks ago

I think I have resolved it. The issue is that the replacement tag needs to be reversed direction when working with RTL