Update Phabricator to work with more modular translations

Summary:
Ref T7152. Ref T1139. This updates Phabricator so third-party libraries can translate their own stuff. Also:

  - Hide "All Caps" when not in development mode, since some users have found this a little confusing.
  - With other changes, adds a "Raw Strings" mode (development mode only).
  - Add an example silly translation to make sure the serious business flag works.
  - Add a basic British English translation.
  - Simplify handling of translation overrides.

Test Plan:
  - Flipped serious business / development on and off and saw silly/development translations drop off.
  - Switched to "All Caps" and saw all caps.
  - Switched to Very English, Wow!
  - Switched to British english and saw "colour".

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7152, T1139

Differential Revision: https://secure.phabricator.com/D11747
This commit is contained in:
epriestley
2015-02-11 13:02:35 -08:00
parent 187836b8a9
commit d4680a7e4e
14 changed files with 137 additions and 149 deletions

View File

@@ -1,33 +1,33 @@
@title Internationalization
@group developer
What is required from developers to get Phabricator translatable.
Describes Phabricator translation and localization.
= API =
Overview
========
Translator API is provided by libphutil. It gives us
@{class@libphutil:PhutilTranslator} class and global @{function@libphutil:pht}
function built on top of it.
Phabricator partially supports internationalization, but many of the tools
are missing or in a prototype state.
Developers are supposed to call @{function@libphutil:pht} on all strings that
require translation.
This document very briefly summarizes some of what exists today.
Phabricator provides translations for this translator through
@{class:PhabricatorTranslation} class.
Writing Translatable Code
========
= Adding a New Translation =
Strings are marked for translation with @{function@libphutil:pht}.
Adding a translation which uses the same language rules as some already existing
translation is relatively simple: Just extend @{class:PhabricatorTranslation}
and you will be able to specify this class in the global configuration
'translation.provider' and users will be able to select it in their preferences.
Adding a New Locale
=========
= Adding a New Language =
To add a new locale, subclass @{class:PhutilLocale}.
Adding a language involves all steps as adding a translation plus specifying the
language rules in @{method@libphutil:PhutilTranslator::chooseVariant}.
Translating Strings
========
= Singular and Plural =
To translate strings, subclass @{class:PhutilTranslation}.
Singular and Plural
========
Different languages have various rules for using singular and plural. All you
need to do is to call @{function@libphutil:pht} with a text that is suitable for
@@ -46,7 +46,8 @@ Translators will translate this text for all different forms the language uses:
The ugly identifier passed to @{function@libphutil:pht} will remain in the text
only if the translation doesn't exist.
= Male and Female =
Male and Female
========
Different languages use different words for talking about males, females and
unknown genders. Callsites have to call @{function@libphutil:pht} passing