YAML for language with only "other" plural form incompatible with Rails

In my Rails project, I have translation keys with plural forms in the source language of English such as:

en:
  errors:
    messages:
      not_saved:
        one: '1 error prohibited this %{resource} from being saved:'
        other: "%{count} errors prohibited this %{resource} from being saved:"

I have this string translated into Chinese (Simplified) zh_CN. Upon tx pull, my translation file contains:

zh_CN:
  errors:
    messages:
      not_saved:
        other: "发生 %{count} 个错误,导致%{resource}保存失败:"

This causes an error on use with Rails:

ActionView::Template::Error:
       translation data {:other=>"发生 %{count} 个错误,导致%{resource}保存失败:"} can not be used with :count => 1. key 'one' is missing.

What Rails is expecting here is:

zh-CN:
  errors:
    messages:
      not_saved: "发生 %{count} 个错误,导致%{resource}保存失败:"

Is there a way to have the file in the format that Rails wants, or am I just gonna have to post-process this somehow?

Actually, I believe this behaviour is due to my test environment loading I18n but not the pluralization rules provided by rails-i18n. So nevermind.

Hi @flagman

My name is Carlos, thanks for contacting Transifex support. Are you still experiencing the issue in your plural translation?

I’m attendant to your comments,
Kind regards

Hello! Could you please share your .tx/config file with us? Thank you in advance.

Why this file is important here? I’m seriously interested how it influences recognition of plural form.

Hello @syl,

After examining the issue shown in the images, I don’t believe the tx/config file is necessary to identify the core problem, but having it is useful for us CSEs to recreate issues accurately and better understand and resolve them.

The issue appears to be with the YAML structure and nesting of the translation files rather than the Transifex configuration.

The main problem visible in the screenshots is that Rails expects a YAML structure that is different from what’s being provided. Specifically:

  1. The current problematic structure has:
zh_CN:
  errors:
    messages:
      not_saved:
        other: "发生 %{count} 个错误,导致%{resource}保存失败:"
  1. While Rails expects:
zh_CN:
  errors:
    messages:
      not_saved: "发生 %{count} 个错误,导致%{resource}保存失败:"

The issue stems from the additional nesting of the other key, which appears to be coming from the plural form handling in the English source file. This is a structural YAML issue rather than a Transifex configuration problem.

I hope this helps!

Which of your tools should be used to get feedback about wrong syntax for plural form? I mean Transifex API, your GitHub Action or what is able to help here? Do you support this kind of error or warning?

Subject: Assistance with Plural Forms Validation

Hi @Syl,

Thank you for reaching out to Transifex Support. My name is Carlos, and I’ll be assisting you with your inquiry.

Unfortunately, at this time, Transifex does not support validating errors or warnings related to plural forms directly within the platform. I completely understand how important this functionality is, and I regret any inconvenience this may cause.

To validate pluralized strings, you would need to perform this step outside of Transifex before pushing the content. If the pluralized string does not align with the expected structure, Transifex will format it as a regular string.

I’m here to help and ensure you have all the support you need. Please don’t hesitate to share any additional questions or concerns, and I’ll do my best to assist further.

Best regards,

Carlos

No confirmation of any kind that Transifex recognized 5 or 15 pluralized strings after pushing new strings to base language?

Thank you again for a great support here.

Hi @syl

At the moment there is no confirmation on Transifex side that let you know how many pluralized strings were detected. What you can do is to filter in the Editor using pluralized:yes filter, this will show you all the pluralized strings inside an specific resource.

Best regards,

Yes, I know about pluralized:yes but it is available for translators and not for developers (scripts, etc.).

Thank you again for support.