Page MenuHomePhabricator

Allow locale definitions to provide gender/plural rules
ClosedPublic

Authored by epriestley on May 25 2016, 9:06 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 10, 8:30 AM
Unknown Object (File)
Mon, Nov 4, 5:13 PM
Unknown Object (File)
Mon, Nov 4, 5:12 PM
Unknown Object (File)
Sun, Nov 3, 6:29 AM
Unknown Object (File)
Oct 24 2024, 9:18 PM
Unknown Object (File)
Oct 23 2024, 9:44 PM
Unknown Object (File)
Oct 23 2024, 2:28 PM
Unknown Object (File)
Oct 9 2024, 12:18 PM
Subscribers

Details

Summary

Ref T5267. Currently, locale definitions can't truly be added in a fully modular way because they aren't free to define their own gender/plural rules.

Allow them to define custom rules. For a small set of popular languages, retain a small performance improvement (this measured as about ~5% for single-parameter strings on my machine). This is optional and just allows languages with simple rules to evaluate very slightly faster with upstream support.

If you load two modules that both define an fr_FR locale (or you define an fr_FR locale, and then we later define one upstream) there will be a conflict, so there still needs to be some upstream/downstream coordination in the long run, but you no longer need to fork or get anything upstreamed to get started. And there are no conflicts with defining a fully-custom locale like en_cloud2butt.

Also inline one idx() call since I was profiling stuff anyway. This was 1-2% faster on my machine.

Test Plan
  • Wrote a test script that translated %s thing(s) in a loop, measured performance cost, saw ~5% for letting locales handle these rules themselves, which seems reasonable.
  • Measured performance cost of idx(), saw numbers 1-2% better by inlining. This is very micro-optimizey but I think worthwhile in pht() since it's used everywhere and often appears somewhere relatively high up on profiles.
  • Ran unit tests, which have reasonable coverage of things like the czech rules.
  • Browsed around and looked at strings.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

epriestley retitled this revision from to Allow locale definitions to provide gender/plural rules.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
chad edited edge metadata.
This revision is now accepted and ready to land.May 25 2016, 10:47 PM
This revision was automatically updated to reflect the committed changes.