Commit 347045e9 authored by Dries's avatar Dries

- Patch #1188430 by Gábor Hojtsy: Rip out textgroup support from locale module.

parent 78a1c38f
This diff is collapsed.
......@@ -779,12 +779,6 @@ function locale_translate_import_form($form) {
'#default_value' => $default,
'#description' => t('Choose the language you want to add strings into. If you choose a language which is not yet set up, it will be added.'),
);
$form['import']['group'] = array('#type' => 'radios',
'#title' => t('Text group'),
'#default_value' => 'default',
'#options' => module_invoke_all('locale', 'groups'),
'#description' => t('Imported translations will be added to this text group.'),
);
$form['import']['mode'] = array('#type' => 'radios',
'#title' => t('Mode'),
'#default_value' => LOCALE_IMPORT_KEEP,
......@@ -818,7 +812,7 @@ function locale_translate_import_form_submit($form, &$form_state) {
}
// Now import strings into the language
if ($return = _locale_import_po($file, $langcode, $form_state['values']['mode'], $form_state['values']['group']) == FALSE) {
if ($return = _locale_import_po($file, $langcode, $form_state['values']['mode']) == FALSE) {
$variables = array('%filename' => $file->filename);
drupal_set_message(t('The translation import of %filename failed.', $variables), 'error');
watchdog('locale', 'The translation import of %filename failed.', $variables, WATCHDOG_ERROR);
......@@ -868,11 +862,6 @@ function locale_translate_export_po_form($form, &$form_state, $names) {
'#options' => $names,
'#description' => t('Select the language to export in Gettext Portable Object (<em>.po</em>) format.'),
);
$form['group'] = array('#type' => 'radios',
'#title' => t('Text group'),
'#default_value' => 'default',
'#options' => module_invoke_all('locale', 'groups'),
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Export'));
return $form;
......@@ -887,11 +876,6 @@ function locale_translate_export_pot_form() {
'#title' => t('Export template'),
'#description' => t('Generate a Gettext Portable Object Template (<em>.pot</em>) file with all strings from the Drupal locale database.'),
);
$form['group'] = array('#type' => 'radios',
'#title' => t('Text group'),
'#default_value' => 'default',
'#options' => module_invoke_all('locale', 'groups'),
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Export'));
// Reuse PO export submission callback.
......@@ -909,7 +893,7 @@ function locale_translate_export_po_form_submit($form, &$form_state) {
$languages = language_list();
$language = $languages[$form_state['values']['langcode']];
}
_locale_export_po($language, _locale_export_po_generate($language, _locale_export_get_strings($language, $form_state['values']['group'])));
_locale_export_po($language, _locale_export_po_generate($language, _locale_export_get_strings($language)));
}
/**
......
......@@ -10,19 +10,6 @@
* @{
*/
/**
* Allows modules to define their own text groups that can be translated.
*
* @param $op
* Type of operation. Currently, only supports 'groups'.
*/
function hook_locale($op = 'groups') {
switch ($op) {
case 'groups':
return array('custom' => t('Custom'));
}
}
/**
* Allows modules to act after language initialization has been performed.
*
......
......@@ -177,13 +177,6 @@ function locale_schema() {
'size' => 'big',
'description' => 'Drupal path in case of online discovered translations or file path in case of imported strings.',
),
'textgroup' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'default',
'description' => 'A module defined group of translations, see hook_locale().',
),
'source' => array(
'type' => 'text',
'mysql_type' => 'blob',
......
......@@ -48,8 +48,7 @@ function locale_help($path, $arg) {
$output = '<p>' . t('Determine the language from a request/session parameter. Example: "http://example.com?language=de" sets language to German based on the use of "de" within the "language" parameter.') . '</p>';
return $output;
case 'admin/config/regional/translate':
$output = '<p>' . t('This page provides an overview of available translatable strings. Drupal displays translatable strings in text groups; modules may define additional text groups containing other translatable strings. Because text groups provide a method of grouping related strings, they are often used to focus translation efforts on specific areas of the Drupal interface.') . '</p>';
$output .= '<p>' . t('See the <a href="@languages">Languages page</a> for more information on adding support for additional languages.', array('@languages' => url('admin/config/regional/language'))) . '</p>';
$output = '<p>' . t('This page provides an overview of available translatable strings. See the <a href="@languages">Languages page</a> for more information on adding support for additional languages.', array('@languages' => url('admin/config/regional/language'))) . '</p>';
return $output;
case 'admin/config/regional/translate/import':
$output = '<p>' . t('This page imports the translated strings contained in an individual Gettext Portable Object (<em>.po</em>) file. Normally distributed as part of a translation package (each translation package may contain several <em>.po</em> files), a <em>.po</em> file may need to be imported after offline editing in a Gettext translation editor. Importing an individual <em>.po</em> file may be a lengthy process.') . '</p>';
......@@ -58,7 +57,7 @@ function locale_help($path, $arg) {
case 'admin/config/regional/translate/export':
return '<p>' . t('This page exports the translated strings used by your site. An export file may be in Gettext Portable Object (<em>.po</em>) form, which includes both the original string and the translation (used to share translations with others), or in Gettext Portable Object Template (<em>.pot</em>) form, which includes the original strings only (used to create new translations with a Gettext translation editor).') . '</p>';
case 'admin/config/regional/translate/translate':
return '<p>' . t('This page allows a translator to search for specific translated and untranslated strings, and is used when creating or editing translations. (Note: For translation tasks involving many strings, it may be more convenient to <a href="@export">export</a> strings for offline editing in a desktop Gettext translation editor.) Searches may be limited to strings found within a specific text group or in a specific language.', array('@export' => url('admin/config/regional/translate/export'))) . '</p>';
return '<p>' . t('This page allows a translator to search for specific translated and untranslated strings, and is used when creating or editing translations. (Note: For translation tasks involving many strings, it may be more convenient to <a href="@export">export</a> strings for offline editing in a desktop Gettext translation editor.) Searches may be limited to strings in a specific language.', array('@export' => url('admin/config/regional/translate/export'))) . '</p>';
case 'admin/structure/block/manage/%/%':
if ($arg[4] == 'locale' && $arg[5] == 'language') {
return '<p>' . t('This block is only shown if <a href="@languages">at least two languages are enabled</a> and <a href="@configuration">language negotiation</a> is set to <em>URL</em> or <em>Session</em>.', array('@languages' => url('admin/config/regional/language'), '@configuration' => url('admin/config/regional/language/configure'))) . '</p>';
......@@ -257,16 +256,6 @@ function locale_permission() {
);
}
/**
* Implements hook_locale().
*/
function locale_locale($op = 'groups') {
switch ($op) {
case 'groups':
return array('default' => t('Built-in interface'));
}
}
/**
* Form builder callback to display language selection widget.
*
......@@ -655,7 +644,7 @@ function locale($string = NULL, $context = NULL, $langcode = NULL) {
// Refresh database stored cache of translations for given language.
// We only store short strings used in current version, to improve
// performance and consume less memory.
$result = db_query("SELECT s.source, s.context, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.textgroup = 'default' AND s.version = :version AND LENGTH(s.source) < :length", array(':language' => $langcode, ':version' => VERSION, ':length' => variable_get('locale_cache_length', 75)));
$result = db_query("SELECT s.source, s.context, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.version = :version AND LENGTH(s.source) < :length", array(':language' => $langcode, ':version' => VERSION, ':length' => variable_get('locale_cache_length', 75)));
foreach ($result as $data) {
$locale_t[$langcode][$data->context][$data->source] = (empty($data->translation) ? TRUE : $data->translation);
}
......@@ -669,7 +658,7 @@ function locale($string = NULL, $context = NULL, $langcode = NULL) {
if (!isset($locale_t[$langcode][$context][$string])) {
// We do not have this translation cached, so get it from the DB.
$translation = db_query("SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context AND s.textgroup = 'default'", array(
$translation = db_query("SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context", array(
':language' => $langcode,
':source' => $string,
':context' => (string) $context,
......@@ -697,7 +686,6 @@ function locale($string = NULL, $context = NULL, $langcode = NULL) {
'location' => request_uri(),
'source' => $string,
'context' => (string) $context,
'textgroup' => 'default',
'version' => VERSION,
))
->execute();
......
This diff is collapsed.
......@@ -247,7 +247,6 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'string' => $name,
'language' => 'all',
'translation' => 'all',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
// assertText() seems to remove the input field where $name always could be
......@@ -302,7 +301,6 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'string' => $name,
'language' => 'all',
'translation' => 'all',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
// Assume this is the only result, given the random name.
......@@ -357,9 +355,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
// table and translate it.
$query = db_select('locales_source', 'l');
$query->addExpression('min(l.lid)', 'lid');
$result = $query->condition('l.location', '%.js%', 'LIKE')
->condition('l.textgroup', 'default')
->execute();
$result = $query->condition('l.location', '%.js%', 'LIKE')->execute();
$url = 'admin/config/regional/translate/edit/' . $result->fetchObject()->lid;
$edit = array('translations['. $langcode .']' => $this->randomName());
$this->drupalPost($url, $edit, t('Save translations'));
......@@ -431,7 +427,6 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'string' => $name,
'language' => 'all',
'translation' => 'all',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
// Find the edit path.
......@@ -497,7 +492,6 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'string' => $name,
'language' => 'all',
'translation' => 'all',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
// assertText() seems to remove the input field where $name always could be
......@@ -511,7 +505,6 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'string' => $name,
'language' => 'all',
'translation' => 'translated',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), t("Search didn't find the string."));
......@@ -522,7 +515,6 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'string' => $name,
'language' => 'all',
'translation' => 'untranslated',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available.'), t('Search found the string.'));
......@@ -545,7 +537,6 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'string' => $translation,
'language' => 'all',
'translation' => 'translated',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available.'), t('Search found the translation.'));
......@@ -556,7 +547,6 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'string' => $name,
'language' => 'all',
'translation' => 'untranslated',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), t("Search didn't find the source string."));
......@@ -567,7 +557,6 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'string' => $translation,
'language' => 'all',
'translation' => 'untranslated',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), t("Search didn't find the translation."));
......@@ -577,7 +566,6 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'string' => $translation,
'language' => $langcode,
'translation' => 'all',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available.'), t('Search found the translation.'));
......@@ -587,7 +575,6 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'string' => $translation,
'language' => 'en',
'translation' => 'all',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), t("Search didn't find the translation."));
......@@ -598,7 +585,6 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'string' => $unavailable_string,
'language' => 'all',
'translation' => 'all',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), t("Search didn't find the invalid string."));
......@@ -651,7 +637,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
$this->assertEqual($this->getUrl(), url('admin/config/regional/translate', array('absolute' => TRUE)), t('Correct page redirection.'));
// Try importing a .po file with invalid tags in the default text group.
// Try importing a .po file with invalid tags.
$this->importPoFile($this->getBadPoFile(), array(
'langcode' => 'fr',
));
......@@ -662,22 +648,11 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
$this->assertRaw($skip_message, t('Unsafe strings were skipped.'));
// Try importing a .po file with invalid tags in a non default text group.
$this->importPoFile($this->getBadPoFile(), array(
'langcode' => 'fr',
'group' => 'custom',
));
// The import should have created 3 strings.
$this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 3, '%update' => 0, '%delete' => 0)), t('The translation file was successfully imported.'));
// Try importing a .po file which doesn't exist.
$name = $this->randomName(16);
$this->drupalPost('admin/config/regional/translate/import', array(
'langcode' => 'fr',
'files[file]' => $name,
'group' => 'custom',
), t('Import'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/translate/import', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertText(t('File to import not found.'), t('File to import not found message.'));
......@@ -697,7 +672,6 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
'string' => 'Montag',
'language' => 'fr',
'translation' => 'translated',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), t('String not overwritten by imported string.'));
......@@ -719,7 +693,6 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
'string' => 'Montag',
'language' => 'fr',
'translation' => 'translated',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available.'), t('String overwritten by imported string.'));
......@@ -760,7 +733,6 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
'string' => 'lundi',
'language' => $langcode,
'translation' => 'translated',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available.'), t('String successfully imported.'));
......@@ -807,7 +779,6 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
'string' => $str,
'language' => 'all',
'translation' => 'all',
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
// assertText() seems to remove the input field where $str always could be
......@@ -1144,9 +1115,8 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
$user = $this->drupalCreateUser(array('translate interface', 'access administration pages'));
$this->drupalLogin($user);
$this->drupalGet('admin/config/regional/translate/translate');
$string = db_query('SELECT min(lid) AS lid FROM {locales_source} WHERE location LIKE :location AND textgroup = :textgroup', array(
$string = db_query('SELECT min(lid) AS lid FROM {locales_source} WHERE location LIKE :location', array(
':location' => '%.js%',
':textgroup' => 'default',
))->fetchObject();
$edit = array('translations[fr]' => 'french translation');
$this->drupalPost('admin/config/regional/translate/edit/' . $string->lid, $edit, t('Save translations'));
......
......@@ -5,16 +5,6 @@
* Mock module for locale layer tests.
*/
/**
* Implements hook_locale().
*/
function locale_test_locale($op = 'groups') {
switch ($op) {
case 'groups':
return array('custom' => t('Custom'));
}
}
/**
* Implements hook_boot().
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment