Page MenuHomePhabricator

Make translations more modular so third-party libraries can translate their strings
ClosedPublic

Authored by epriestley on Feb 11 2015, 8:00 PM.
Tags
None
Referenced Files
F19134887: D11745.diff
Dec 10 2025, 8:47 AM
F19058394: D11745.diff
Nov 29 2025, 1:55 AM
F19047902: D11745.id.diff
Nov 27 2025, 1:43 PM
F19043306: D11745.diff
Nov 26 2025, 9:13 PM
F19015978: D11745.diff
Nov 23 2025, 2:30 AM
F18916783: D11745.id28320.diff
Nov 9 2025, 9:07 AM
F18916768: D11745.id.diff
Nov 9 2025, 9:06 AM
F18840730: D11745.id.diff
Oct 28 2025, 3:27 AM
Subscribers

Details

Summary

Ref T7152. Ref T1139. This is a little far afield, but I need to translate some "%s thing(s)" strings into English in Instances to complete the invite workflow.

This isn't currently possible because translations are not modular enough: a library can not translate only its own strings.

To fix this:

  • Define PhutilLocale, which provides a target translation language, like "English (US)".
  • Provide PhutilTranslation, which provides some strings in a target language. Libraries can subclass PhutilTranslation to supplement strings.
  • Rework PhutilTranslator to be aware of locales.
  • I also formalized test translations, silly translations, and de-hacked up the "ALL CAPS" translation. The sex/plural rules are still hard-coded for now.
Test Plan

See next two diffs.

Diff Detail

Repository
rPHU libphutil
Branch
xlation1
Lint
Lint Passed
SeverityLocationCodeMessage
Advicesrc/internationalization/PhutilTranslator.php:129XHP16TODO Comment
Unit
Tests Passed
Build Status
Buildable 4462
Build 4476: [Placeholder Plan] Wait for 30 Seconds

Event Timeline

epriestley retitled this revision from to Make translations more modular so third-party libraries can translate their strings.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: btrahan.
btrahan edited edge metadata.
This revision is now accepted and ready to land.Feb 11 2015, 8:28 PM
This revision was automatically updated to reflect the committed changes.