Comments (2)
Thanks, @MichaelHoste. Closing the issue for now.
from rails.
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):
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)
- Gettext translations cached after switching locale? HOT 4
- Special characters in translation HOT 2
- Isn't it possible to only use gettext? HOT 2
- Deprecation warning for #has_rdoc (Rubygems) HOT 2
- Do not add methods on Object HOT 3
- Empty hash in localization.en.yml
- Strings not get synced
- Unclear how to use custom locales in project HOT 5
- Crash on "rake translation:init" HOT 3
- getText method not translating text as supposed to after install and intialization HOT 7
- Deprecation warning on Rails 6 HOT 4
- Error while running `translations:sync`: ArgumentError: comparison of Pathname with String failed HOT 3
- When disabling gettext in the initialiser gettext directory and files are still created HOT 3
- gettext strings missing after use of case statement in erb HOT 20
- A way to exclude translation keys HOT 3
- Ruby 3.1 compatibility (Psych 4 breaking change) HOT 7
- Match I18n fallbacks in GetText HOT 2
- ignore specific files HOT 4
- Error when starting Pushion Passenger HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rails.