function i18nstrings_get_source in Internationalization 6
Get source string provided a string context.
This will search first with the full context parameters and, if not found, it will search again only with textgroup and source string.
Parameters
$context: Context string or object.
Return value
Context object if it exists.
9 calls to i18nstrings_get_source()
- Drupali18nTestCase::i18nstringsSaveTranslation in tests/
drupal_i18n_test_case.php - Translate one string into the db
- i18ncontent_node_help_source in i18ncontent/
i18ncontent.module - Fetch default source for node type help
- i18nstrings_add_l10n_client in i18nstrings/
i18nstrings.module - Add string to l10n strings if enabled and allowed for this string
- i18nstrings_add_string in i18nstrings/
i18nstrings.module - Add source string to the locale tables for translation.
- i18nstrings_remove_string in i18nstrings/
i18nstrings.module - Remove string for a given context.
File
- i18nstrings/
i18nstrings.module, line 520 - Internationalization (i18n) package - translatable strings.
Code
function i18nstrings_get_source($context, $string = NULL) {
$context = i18nstrings_context($context, $string);
// Check if we have the string for this location.
list($where, $args) = i18nstrings_context_query($context);
if ($source = db_fetch_object(db_query("SELECT s.*, i.type, i.objectid, i.property, i.format FROM {locales_source} s LEFT JOIN {i18n_strings} i ON s.lid = i.lid WHERE " . implode(' AND ', $where), $args))) {
$source->context = $context;
return $source;
}
// Search for the same string for this textgroup without object data.
if ($string && ($source = db_fetch_object(db_query("SELECT s.*, i.type, i.objectid, i.property, i.format FROM {locales_source} s LEFT JOIN {i18n_strings} i ON s.lid = i.lid WHERE s.textgroup = '%s' AND s.source = '%s' AND i.lid IS NULL", $context->textgroup, $string)))) {
$source->context = NULL;
return $source;
}
}