Git Product home page Git Product logo

Comments (2)

syakovyn avatar syakovyn commented on May 12, 2024 1

Thanks, @MichaelHoste. Closing the issue for now.

from rails.

MichaelHoste avatar MichaelHoste commented on May 12, 2024

Hi Serhiy,

As you noticed, zero, one, two, few, many and other are special keywords for Ruby on Rails I18n system to deal with plurals: https://guides.rubyonrails.org/i18n.html#pluralization

The thing is, since each language is different regarding pluralization, and English (the most common source language) only uses one and other (also zero but it's optional), you should add placeholders for other plural forms instead of leaving them empty. That's why you have redundant keys in the English YAML file.

You can even add some comments in the "non-english" plural forms to guide your translators:

students_count:
  zero:  '0 students'
  one:   '1 student'
  two:   '2 students [NOTE: TRANSLATE WHEN "TWO" PLURAL FORM IS USEFUL]'
  few:   '%{count} students [NOTE: TRANSLATE WHEN "FEW" PLURAL FORM IS USEFUL]'
  many:  '%{count} students [NOTE: TRANSLATE WHEN "MANY" PLURAL FORM IS USEFUL]'
  other: '%{count} students'

You can also give global instructions to the translators, or add a special "don't translate" tag using a filter like .few on the translation interface that will filter all of them.

I know that it's not a very clean way to work, but we can't automate this during the "sync", because zero, one, two, (...) are not special keys. They are just regular YAML keys, and Rails deals with them in a special way using conventions. Nothing prevents you from using a few key elsewhere in you YAML file without any intention to use plurals. And we don't want to mess with that.

What we usually do, is to mix YAML and GetText syntaxes in our projects, and the GetText way to pluralize is way nicer:

# Pluralization
n_("Singular text", "Plural text", number)

GetText pluralizations are easy to write and are grouped in a single segment.
The translation interface will adapt depending on the target language (1, 2, 3 or 4 plural forms):

Screenshot 2020-11-26 at 00 17 01

It should be easier to code (just write it in English) and easier for the translator to understand (we hide in the interface plural forms that are not useful)

I hope it helped.

from rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.