Page MenuHomePhabricator

Allow translator to return the base string if no translation is available
Closed, ResolvedPublic

Description

I currently working on a translation project for phabricator. Extracted all the string with i18n binary and created the translation classes.
If a string is empty (null by default) tha PhutilTranslator::translate() method returns an empty string.
It is no so easy to make translation, I recommend to allow translate() method to return the original input ($text) if the translated string ($result in this case) is empty.

Event Timeline

Zolli raised the priority of this task from to Normal.
Zolli updated the task description. (Show Details)
Zolli added a project: Localization.
Zolli added a subscriber: Zolli.
epriestley claimed this task.
epriestley added a subscriber: epriestley.

Just have your translation provider class do something like:

foreach ($translations as $key => $value) {
  if ($value === null) {
    unset($translations[$key]);
  }
}

..before returning translated strings. We may eventually formalize this (e.g., make translation classes do this automatically), but this isn't a priority for now.

Zolli changed the task status from Wontfix to Resolved.Jan 1 2015, 4:21 PM

Completed with D11121