i18nstrings_add_string($name, $string)
contributions/i18n/i18nstrings/i18nstrings.module, line 220
Add string
This function checks for already existing string without context for this textgroup
Update status
<?php
function i18nstrings_add_string($name, $string) {
$context = i18nstrings_context($name);
$location = i18nstrings_location($context);
// Check if we have a source string
$source = i18nstrings_get_source($context, $string);
$status = -1;
if ($source) {
if ($source->source != $string || $source->location != $location) {
// String has changed or didnt have location
db_query("UPDATE {locales_source} SET source = '%s' WHERE lid = %d", $string, $source->lid);
$status = SAVED_UPDATED;
}
}
else {
db_query("INSERT INTO {locales_source} (location, source, textgroup, version) VALUES ('%s', '%s', '%s', '%s')", $location, $string, $context->textgroup, 0);
// Clear locale cache so this string can be added in a later request.
cache_clear_all('locale:'.$context->textgroup.':', 'cache', TRUE);
// Create string
$source->lid = db_last_insert_id('locales_source', 'lid');
$status = SAVED_NEW;
}
// Update metadata
db_query("DELETE FROM {i18n_strings} WHERE lid = %d", $source->lid);
db_query("INSERT INTO {i18n_strings} (lid, type, oid, property) VALUES(%d, '%s', %d, '%s')", $source->lid, $context->type, $context->oid, $context->property);
return $status;
}
?>