Homec4science

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

Authored by epriestley <git@epriestley.com> on Feb 11 2015, 22:01.

Description

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

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.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7152, T1139

Differential Revision: https://secure.phabricator.com/D11745

Details

Committed
epriestley <git@epriestley.com>Feb 11 2015, 22:01
Pushed
aubortMar 17 2017, 12:03
Parents
rPHUf47f8d27fc30: Add trailing whitespace
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPHU4252753ed7b9: Make translations more modular so third-party libraries can translate their… (authored by epriestley <git@epriestley.com>).Feb 11 2015, 22:01