You are here

function _l10n_client_page_strings in Localization client 5

Same name and namespace in other branches
  1. 6.2 l10n_client.module \_l10n_client_page_strings()
  2. 6 l10n_client.module \_l10n_client_page_strings()
  3. 7 l10n_client.module \_l10n_client_page_strings()

Get the strings to translate for this page. These will be:

  • The ones added in $l10n_client_strings by this or other modules
  • The strings tored by the local function (not for for this module's own pages)

Any module can add strings to translate into the global variable $l10n_client_strings

1 call to _l10n_client_page_strings()
l10n_client_footer in ./l10n_client.module
Implementation of hook_footer().

File

./l10n_client.module, line 226
Localization client. Provides on-page translation editing.

Code

function _l10n_client_page_strings() {
  global $locale, $l10n_client_strings;

  // Get the page strins stored by this or other modules
  $strings = !empty($l10n_client_strings) ? $l10n_client_strings : array();

  // If this is not the module's translation page, merge all strings used on the page.
  if (arg(0) != 'locale' && is_array($locale_strings = locale())) {
    $strings = array_merge($strings, $locale_strings);

    // Also select other strings for this path.
    // Other users may have run into these strings for the same page.
    $result = db_query("SELECT s.source, t.translation FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.locale = '%s' WHERE location = '%s'", $locale, request_uri());
    while ($data = db_fetch_object($result)) {
      if (!array_key_exists($data->source, $strings)) {
        $strings[$data->source] = empty($data->translation) ? TRUE : $data->translation;
      }
    }
  }
  return $strings;
}