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)
Mon, Mar 18, 7:23 PM
Unknown Object (File)
Mon, Mar 18, 5:53 PM
Unknown Object (File)
Sun, Mar 17, 7:27 PM
Unknown Object (File)
Sun, Mar 17, 4:54 PM
Unknown Object (File)
Sat, Mar 16, 12:49 AM
Unknown Object (File)
Fri, Mar 15, 3:01 PM
Unknown Object (File)
Feb 17 2024, 12:36 PM
Unknown Object (File)
Feb 16 2024, 11:11 AM
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.