Page MenuHomePhabricator

Make it more clear when a translation provides bad variants
ClosedPublic

Authored by epriestley on Mar 29 2016, 12:31 PM.
Tags
None
Referenced Files
F12831630: D15545.diff
Thu, Mar 28, 12:54 PM
Unknown Object (File)
Tue, Mar 5, 1:32 AM
Unknown Object (File)
Jan 31 2024, 10:55 AM
Unknown Object (File)
Jan 28 2024, 2:50 AM
Unknown Object (File)
Dec 29 2023, 3:32 AM
Unknown Object (File)
Dec 27 2023, 6:24 AM
Unknown Object (File)
Dec 23 2023, 6:09 AM
Unknown Object (File)
Dec 21 2023, 1:08 PM
Subscribers
None

Details

Summary

Ref T10688. When you have a translation like "I saw %s dog(s)", you can provide multiple variants in the translation file that are selected based on the argument's plurality or gender.

However, if you pass something which is not a number and not gendered, we can't use it to choose a variant (we have no idea which variant we should select for a phutil_tag() or arbitrary string).

An example of bad variant data is:

'%s touched %s %s time(s).' => array(
  array(
    '%s touched %s once.',
    '%s touched %s %s times.',
  )
)

This data intends to vary on the third parameter (the number of touches) but actually varies on the second parameter (the touched thing).

Unless that second parameter is a number or a person, this data is incorrect and tries to vary on a non-gendered, non-plural value.

The correct data uses an extra array to vary on the third parameter instead of the second parameter:

'%s touched %s %s time(s).' => array(
  array(
    array(
      '%s touched %s once.',
      '%s touched %s %s times.',     
    )
  )
)
Test Plan

Screen Shot 2016-03-29 at 5.26.49 AM.png (640×1 px, 171 KB)

Diff Detail

Repository
rPHU libphutil
Branch
badvariants
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 11343
Build 14116: Run Core Tests
Build 14115: arc lint + arc unit

Event Timeline

epriestley retitled this revision from to Make it more clear when a translation provides bad variants.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added reviewers: chad, lpriestley.
chad edited edge metadata.
This revision is now accepted and ready to land.Mar 29 2016, 1:47 PM
This revision was automatically updated to reflect the committed changes.