I'm looking for a simple-proper-elegant way to handle grammatical gender with Gettext in a Rails application, the same way plurals are handled with n_()
method.
This has no interest in english, since words don't vary with gender, but it does when translating into spanish. His / her is a good use case in english. This is really needed when translating into spanish.
An example:
Considering users Pablo (male) and Ana María (female).
_('%{user} is tall') & {:user => user.name}
Should be translated to
'Pablo es alto'
'Ana María es alta'
Of course, we have access to user.gender
Any ideas?
Cheers!
Using standard gettext features this can be solved using contexts. Like calling appropriate:
p_('Male', '%{user} is tall')
or
p_('Female', '%{user} is tall')
This will generate two separate strings in gettext catalogs marking them with "Male" and "Female" contexts.