diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-09-01 12:50:47 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-09-01 12:50:47 +0000 |
commit | 0fd16236efd4eca6e229e6e6a4d06ba488aa06e1 (patch) | |
tree | 6c095ca383d19073f89a8f99e24a02edd5b6753d /modules/locale | |
parent | f7ee91227ed6def55d736d3063902b405546d58f (diff) | |
download | brdo-0fd16236efd4eca6e229e6e6a4d06ba488aa06e1.tar.gz brdo-0fd16236efd4eca6e229e6e6a4d06ba488aa06e1.tar.bz2 |
#171562 by JirkaRybka: fix several issues with locales
- make searches work again, better worded
- do not cache English stuff
- fix strike through on string seek page
- fix exports for translations
Diffstat (limited to 'modules/locale')
-rw-r--r-- | modules/locale/locale.module | 24 | ||||
-rw-r--r-- | modules/locale/locale.schema | 2 |
2 files changed, 10 insertions, 16 deletions
diff --git a/modules/locale/locale.module b/modules/locale/locale.module index 417f99f19..a9eb60014 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -331,22 +331,15 @@ function locale($string = NULL, $langcode = NULL) { } } - // We have the translation cached (if it is TRUE, then there is no - // translation, so there is no point in checking the database) - if (isset($locale_t[$langcode][$string])) { - $string = ($locale_t[$langcode][$string] === TRUE ? $string : $locale_t[$langcode][$string]); - } + // If we have the translation cached, skip checking the database + if (!isset($locale_t[$langcode][$string])) { - // We do not have this translation cached, so get it from the DB. - else { - $translation = db_fetch_object(db_query("SELECT s.lid, t.translation FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid WHERE s.source = '%s' AND t.language = '%s' AND s.textgroup = 'default'", $string, $langcode)); + // We do not have this translation cached, so get it from the DB. + $translation = db_fetch_object(db_query("SELECT s.lid, t.translation FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.source = '%s' AND s.textgroup = 'default'", $langcode, $string)); if ($translation) { // We have the source string at least. - if ($translation->lid) { - // Cache translation string or TRUE if no translation exists. - $translation = (empty($translation->translation) ? TRUE : $translation->translation); - $locale_t[$langcode][$string] = $translation; - } + // Cache translation string or TRUE if no translation exists. + $locale_t[$langcode][$string] = (empty($translation->translation) ? TRUE : $translation->translation); } else { // We don't have the source string, cache this as untranslated. @@ -357,7 +350,7 @@ function locale($string = NULL, $langcode = NULL) { } } - return $string; + return ($locale_t[$langcode][$string] === TRUE ? $string : $locale_t[$langcode][$string]); } /** @@ -368,9 +361,10 @@ function locale($string = NULL, $langcode = NULL) { function locale_refresh_cache() { $languages = language_list('enabled'); $languages = $languages['1']; + unset($languages['en']); foreach ($languages as $language) { - $result = db_query("SELECT s.source, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid WHERE t.language = '%s' AND s.textgroup = 'default' AND LENGTH(s.source) < 75", $language->language); + $result = db_query("SELECT s.source, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = 'default' AND LENGTH(s.source) < 75", $language->language); $t = array(); while ($data = db_fetch_object($result)) { $t[$data->source] = (empty($data->translation) ? TRUE : $data->translation); diff --git a/modules/locale/locale.schema b/modules/locale/locale.schema index 70d4fbb5c..f511a020f 100644 --- a/modules/locale/locale.schema +++ b/modules/locale/locale.schema @@ -37,7 +37,7 @@ function locale_schema() { // Drupal path in case of online discovered translations or file path in case of imported strings. 'location' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), // A module defined group of translations, see hook_locale(). - 'textgroup' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), + 'textgroup' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'default'), // The original string in English. 'source' => array('type' => 'text', 'mysql_type' => 'blob', 'not null' => TRUE), ), |