You are here

function finder_i18nstrings_translate_strings in Finder 7

Same name and namespace in other branches
  1. 6 modules/finder_i18nstrings/finder_i18nstrings.module \finder_i18nstrings_translate_strings()

Recursively translate strings using the map.

1 call to finder_i18nstrings_translate_strings()
finder_i18nstrings_finderapi in modules/finder_i18nstrings/finder_i18nstrings.module
Implements hook_finderapi().

File

modules/finder_i18nstrings/finder_i18nstrings.module, line 217
The finder string translation module.

Code

function finder_i18nstrings_translate_strings(&$object, $map) {
  if (!empty($map)) {
    $was_object = FALSE;
    if (is_object($object)) {
      $was_object = TRUE;
      $object = (array) $object;
    }
    foreach ($map as $key => $value) {
      if (is_string($object[$key]) && !empty($value['#i18nstrings'])) {
        $object[$key] = i18n_string($value['#i18nstrings'], $object[$key]);
      }
      elseif (is_array($map[$key])) {
        finder_i18nstrings_translate_strings($object[$key], $map[$key]);
      }
    }
    if ($was_object) {
      $object = (object) $object;
    }
  }
}