Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable placeholders getting corrupted while using Google translate API #51

Open
hackerkid opened this issue Jul 1, 2021 · 1 comment

Comments

@hackerkid
Copy link

@leolabs Thanks for building this. This is a fantastic tool with excellent documentation and made my life a lot easier.

But I did face an issue while using this tool.

So I was trying to translate the strings without arabic translations in the following for fixing zulip/zulip#18933.

https://github.com/zulip/zulip/blob/05352f417a8f163ee8bda1fc1593875c432c5297/locale/ar/translations.json.

npx json-autotranslate -t natural --matcher icu -d -i locale -c google-key.json

The command completed sucesfully. But 17 strings ended up having the variable names corrupted. There are 55 strings with a variables in the file. So around 30% of the strings ended up being corrupted. I guess the good news is 70% got translated correctly :)

Here are the list of strings that were corrupted. The first line contains the string in English and the second line contains the translation in Arabic.


```bash
Are you sure you want to mention all <strong>__count__</strong> people in this stream? <br> This will send email and mobile push notifications to most of those <strong>__count__</strong> users. <br> If you don't want to do that, please edit your message to remove the <strong>@__mention__</strong> mention.
هل تريد بالتأكيد ذكر جميع <strong>__count__ من</strong> الأشخاص في مجموعة البث هذه؟<br>سيؤدي هذا إلى إرسال إشعارات عبر البريد الإلكتروني والجوال إلى معظم هؤلاء <strong>__العدد__ من</strong> المستخدمين.<br>إذا كنت لا تريد القيام بذلك ، يرجى تعديل رسالتك <strong>لإزالة__mention__</strong> الإشارة.

Message __- recipient_names__
الرسالة __- أسماء المستلمين__

Narrow to stream &quot;__display_recipient__&quot;
ضيق للدفق & quot؛ __ display_recipient __ & quot؛

Narrow to stream &quot;__display_recipient__&quot;, topic &quot;__topic__&quot;
ضيق للدفق & quot؛ __ display_recipient __ & quot ؛، موضوع & quot؛ __ موضوع __ & quot؛

Narrow to your private messages with __display_reply_to__
تضييق نطاق رسائلك الخاصة باستخدام __عرض_الرد على_تو__

Organization using __percent_used__% of __upload_quota__.
منظمة تستخدم __percent_used __٪ من __upload_quota__.

Owner: __name__
اسم المالك__

This organization is configured to restrict editing of message content to __minutes_to_edit__ minutes after it is sent.
تم تكوين هذه المؤسسة لتقييد تحرير محتوى الرسالة بـ __دقائق_لتحرير__ دقائق بعد إرسالها.

You (click to remove) reacted with __- emoji_name__
لقد (انقر للإزالة) تفاعلت بـ __- اسم_إيموجي__

You and __display_reply_to__
أنت و __عرض_الرد على_إلى__

You and __recipients__
أنت و __المستلمون_

You are not subscribed to stream __stream__
أنت غير مشترك في البث __ Stream__

You subscribed to stream __stream__
لقد اشتركت في البث __ Stream__

You unsubscribed from stream __stream__
لقد ألغيت اشتراكك في تيار __ Stream__

__- username__ reacted with __- emoji_name__
__- اسم المستخدم__ تفاعل بـ __- اسم_إيموجي__

__starred_status__ this message
__ starred_status__ هذه الرسالة

private messages with __- recipient__
رسائل خاصة مع __- المستلم__

Any idea why this happened?

@hackerkid hackerkid changed the title Variable placeholders getting corrupted while usinh Google translate API Variable placeholders getting corrupted while using Google translate API Jul 1, 2021
@leolabs
Copy link
Owner

leolabs commented Jul 11, 2021

It looks like the placeholders aren't in the right format. This tool works either with ICU/i18next placeholders like {email} or with sprintf-style placeholders like %s. I could implement a new matcher that matches placeholders like __email__, but I haven't seen any library that uses them like that. Which library are you using for your translations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants