Commit 0f088b79 authored by Dries's avatar Dries

- Patch #9983 by Stefan: various code style improvements.
parent c1ca7c32
<?php
// $Id$
include_once "includes/bootstrap.inc";
include_once "includes/common.inc";
include_once 'includes/bootstrap.inc';
include_once 'includes/common.inc' ;
// If not in 'safe mode', increase the maximum execution time:
if (!ini_get("safe_mode")) {
if (!ini_get('safe_mode')) {
set_time_limit(240);
}
......
......@@ -1507,7 +1507,7 @@ function update_101() {
// but not the fixed fields
unset($fields['lid'], $fields['location'], $fields['string']);
// insert locales
$list = _locale_get_iso639_list();
foreach ($fields as $key => $value) {
......@@ -1524,7 +1524,7 @@ function update_101() {
}
}
}
// get all strings
$result = db_query('SELECT * FROM {locales}');
while($entry = db_fetch_object($result)) {
......
......@@ -19,7 +19,7 @@ function _locale_add_language($code, $name, $onlylanguage = TRUE) {
while ($string = db_fetch_object($result)) {
db_query("INSERT INTO {locales_target} (lid, locale) VALUES (%d,'%s')", $string->lid, $code);
}
// If only the language was added, and not a PO file import triggered
// the language addition, we need to inform the user on how to start
// a translation
......@@ -29,7 +29,7 @@ function _locale_add_language($code, $name, $onlylanguage = TRUE) {
else {
$message = t("'%locale' language added.", array('%locale' => t($name)));
}
drupal_set_message($message);
watchdog('locale', t("'%locale' language added.", array('%locale' => $code)));
}
......@@ -46,20 +46,20 @@ function _locale_admin_manage_screen() {
foreach ($languages['name'] as $key => $lang) {
$status = db_fetch_object(db_query("SELECT isdefault, enabled FROM {locales_meta} WHERE locale = '%s'", $key));
if ($key == 'en') {
$rows[] = array('en', $lang, form_checkbox('', 'enabled][en', 1, $status->enabled), form_radio('', 'sitedefault', $key, $status->isdefault), message_na(), '');
}
else {
$original = db_fetch_object(db_query("SELECT COUNT(*) AS strings FROM {locales_source}"));
$translation = db_fetch_object(db_query("SELECT COUNT(*) AS translation FROM {locales_target} WHERE locale = '%s' AND translation != ''", $key));
$ratio = ($original->strings > 0 && $translation->translation > 0) ? round(($translation->translation/$original->strings)*100., 2) : 0;
$rows[] = array($key, ($key != 'en' ? form_textfield('', 'name]['. $key, $lang, 15, 64) : $lang), form_checkbox('', 'enabled]['. $key, 1, $status->enabled), form_radio('', 'sitedefault', $key, $status->isdefault), "$translation->translation/$original->strings ($ratio%)", ($key != 'en' ? l(t('delete locale'), 'admin/locale/language/delete/'. urlencode($key)) : ''));
}
}
return form(theme('table', $header, $rows) . form_submit(t('Save configuration')), 'POST', url('admin/locale'));
}
......@@ -67,14 +67,14 @@ function _locale_admin_manage_screen() {
* User interface for the language addition screen
*/
function _locale_admin_manage_add_screen() {
$isocodes = _locale_prepare_iso_list();
$output = '<h2>'. t('From language list') .'</h2>';
$form = form_select(t('Language name'), 'langcode', key($isocodes), $isocodes, t('Select your language here, or add it below, if you are unable to find it.'));
$form .= form_submit(t('Add language'));
$output .= form($form);
$edit = &$_POST['edit'];
$output .= '<h2>'. t('Custom language') .'</h2>';
$form = form_textfield(t('Language code'), 'langcode', $edit['langcode'], 70, 12, t("Commonly this is an <a href=\"%iso-codes\">ISO 639 language code</a> with an optional country code for regional variants. Examples include 'en', 'en-US' and 'zh-cn'.", array("%iso-codes" => "http://www.w3.org/WAI/ER/IG/ert/iso639.htm")));
......@@ -93,7 +93,7 @@ function _locale_admin_import_screen() {
$languages = locale_supported_languages(FALSE, TRUE);
$languages = array_map("t", $languages['name']);
unset($languages['en']);
if (!count($languages)) {
drupal_set_message(t('You need to have at least one language set up to import translations.'), 'error');
}
......@@ -102,7 +102,7 @@ function _locale_admin_import_screen() {
t('Already added languages') => $languages,
t('Languages not yet added') => _locale_prepare_iso_list()
);
$form = form_file(t('Language file'), 'file', 50, t('A gettext Portable Object (.po) file.'));
$form .= form_select(t('Import into'), 'langcode', '', $languages, t('Choose the language you want to add strings into. If you choose a language which is not yet set up, then it will be added.'));
$form .= form_radios(t('Mode'), 'mode', 'overwrite', array("overwrite" => t('Strings in the uploaded file replace existing ones, new ones are added'), "keep" => t('Existing strings are kept, only new strings are added')));
......@@ -117,7 +117,7 @@ function _locale_admin_import_screen() {
*
* @param $file Name of local file to be imported
* @param $edit Language code
* @param $mode should existing translations be replaced?
* @param $mode should existing translations be replaced?
*/
function _locale_import_po($file, $lang, $mode) {
// Check if we have the language already in the database
......@@ -125,21 +125,21 @@ function _locale_import_po($file, $lang, $mode) {
drupal_set_message(t("Unsupported language selected for import."), 'error');
return FALSE;
}
// Check if we can get the strings from the file
if (!($strings = _locale_import_read_po($file))) {
drupal_set_message(t("Translation file broken: Couldn't be read."), 'error');
return FALSE;
}
// Strip out header from the string pairs
$header = $strings[""]["msgstr"];
unset($strings[""]);
// Get information from the header into the database
if ($header) {
$hdr = _locale_import_parse_header($header);
// Get the plural formula
if ($hdr["Plural-Forms"] && $p = _locale_import_parse_plural_forms($hdr["Plural-Forms"])) {
list($nplurals, $plural) = $p;
......@@ -157,7 +157,7 @@ function _locale_import_po($file, $lang, $mode) {
$fullstr = 0;
foreach ($strings as $value) {
$comments = _locale_import_shorten_comments($value['#']);
// Handle a translation for some plural string
if (strpos($value['msgid'], "\0")) {
$english = explode("\0", $value['msgid'], 2);
......@@ -192,7 +192,7 @@ function _locale_import_po($file, $lang, $mode) {
}
}
}
// A simple translation
else {
$english = $value['msgid'];
......@@ -218,7 +218,7 @@ function _locale_import_po($file, $lang, $mode) {
}
}
}
// Successfull import
cache_clear_all("locale:$lang");
drupal_set_message(t("Translation successfully imported. %num translated strings added to language.", array('%num' => $fullstr)));
......@@ -284,7 +284,7 @@ function _locale_import_read_po($path) {
return FALSE;
}
$current["msgid"] = $current["msgid"] ."\0". $quoted;
$context = "MSGID_PLURAL";
$context = "MSGID_PLURAL";
}
elseif (!strncmp("msgid", $line, 5)) {
if ($context == "MSGSTR") { // End current entry, start a new one
......@@ -605,7 +605,7 @@ function _locale_import_tokenize_formula($formula) {
* @param $key Index of the array element
*/
function _locale_import_append_plural($entry, $key) {
// No modifications for 0, 1
// No modifications for 0, 1
if ($key == 0 || $key == 1) {
return $entry;
}
......@@ -674,7 +674,7 @@ function _locale_admin_export_screen() {
$form = t('<p>Generate a gettext Portable Object Template (.pot) file with all the interface strings from the Drupal locale database.</p>');
$form .= form_submit(t('Export'));
$output .= form($form);
return $output;
}
......@@ -685,7 +685,7 @@ function _locale_admin_export_screen() {
*/
function _locale_export_po($language) {
global $user;
// Get language specific strings, or all strings
if ($language) {
$meta = db_fetch_object(db_query("SELECT * FROM {locales_meta} WHERE locale = '%s'", $language));
......@@ -694,7 +694,7 @@ function _locale_export_po($language) {
else {
$result = db_query("SELECT s.lid, s.source, s.location, t.plid, t.plural FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid GROUP BY s.lid ORDER BY t.plid, t.plural");
}
// Build array out of the database results
$parent = array();
while ($child = db_fetch_object($result)) {
......@@ -709,7 +709,7 @@ function _locale_export_po($language) {
$parent[$child->lid]['translation'] = $child->translation;
}
}
// Generating Portable Object file for a language
if ($language) {
$filename = $language .'.po';
......@@ -732,7 +732,7 @@ function _locale_export_po($language) {
$header .= "\n";
watchdog('locale', strtr("PO file for locale '%loc' downloaded.", array('%loc' => $meta->name)));
}
// Generating Portable Object Template
else {
$filename = variable_get('site_name', 'drupal') .'.pot';
......@@ -899,7 +899,7 @@ function _locale_string_save($lid) {
function _locale_string_edit($lid) {
$languages = locale_supported_languages(FALSE, TRUE);
unset($languages['name']['en']);
$result = db_query("SELECT DISTINCT s.source, t.translation, t.locale FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid WHERE s.lid = %d", $lid);
$form = '';
while ($translation = db_fetch_object($result)) {
......@@ -927,7 +927,7 @@ function _locale_string_language_list($translation) {
foreach ($languages['name'] as $key => $value) {
if (isset($translation[$key])) {
$output .= ($translation[$key] != '') ? $key .' ' : "<strike>$key</strike> ";
}
}
}
return $output;
......@@ -996,7 +996,7 @@ function _locale_string_seek() {
break;
// Some different language
default:
$sql = "$join $where AND t.locale = '". check_query($query->language) ."' $orderby";
$sql = "$join $where AND t.locale = '". check_query($query->language) ."' $orderby";
}
$result = pager_query($sql, 50);
......
......@@ -425,7 +425,7 @@ function menu_get_active_help() {
if ($temp = module_invoke($name, 'help', $path)) {
$output .= $temp . "\n";
}
if (substr($path, 0, 6) == "admin/") {
if (substr($path, 0, 6) == "admin/") {
if (module_invoke($name, 'help', 'admin/help#' . substr($path, 6))) {
$output .= theme("more_help_link", url('admin/help/' . substr($path, 6)));
}
......
<?php
// $Id$
include_once "includes/bootstrap.inc";
include_once 'includes/bootstrap.inc';
drupal_page_header();
include_once "includes/common.inc";
include_once 'includes/common.inc';
fix_gpc_magic();
......
......@@ -31,7 +31,7 @@ function aggregator_help($section) {
<p>News items can be filed into categories. To create a category, start at the <a href="%admin-news">aggregation page</a>.</p>
<p>Once there, select <a href="%new-category">new category</a> from the menu. Drupal will then ask for the following:</p>
<ul>
<li><strong>Title</strong> -- The title will be used in the <i>news by topics</i> listing in your news aggregator and for the block created for the bundle.</li>
<li><strong>Title</strong> -- The title will be used in the <em>news by topics</em> listing in your news aggregator and for the block created for the bundle.</li>
<li><strong>Description</strong> -- A short description of the category to tell users more details about what news items they might find in the category.</li>
<li><strong>Latest items block</strong> -- The number of items selected here will determine how many of the latest items from the category will appear in a block which may be enabled and placed in the <a href="%block">blocks</a> administration page.</li>
</ul>
......@@ -61,7 +61,7 @@ function aggregator_help($section) {
case 'admin/aggregator/add/feed':
return t('Add a site that has an RSS/RDF feed. The URL is the full path to the RSS feed file. For the feed to update automatically you must run "cron.php" on a regular basis. If you already have a feed with the URL you are planning to use, the system will not accept another feed with the same URL.');
case 'admin/aggregator/add/category':
return t('Categories provide a way to group items from different news feeds together. Each news category has its own feed page and block. For example, you could tag various sport-related feeds as belonging to a category called <i>Sports</i>. News items can be added to a category automatically by setting a feed to automatically place its item into that category, or by using the categorize items link in any listing of news items.');
return t('Categories provide a way to group items from different news feeds together. Each news category has its own feed page and block. For example, you could tag various sport-related feeds as belonging to a category called <em>Sports</em>. News items can be added to a category automatically by setting a feed to automatically place its item into that category, or by using the categorize items link in any listing of news items.');
case 'admin/aggregator/configure':
return t('These settings control the display of aggregated content.');
}
......
......@@ -31,7 +31,7 @@ function aggregator_help($section) {
<p>News items can be filed into categories. To create a category, start at the <a href="%admin-news">aggregation page</a>.</p>
<p>Once there, select <a href="%new-category">new category</a> from the menu. Drupal will then ask for the following:</p>
<ul>
<li><strong>Title</strong> -- The title will be used in the <i>news by topics</i> listing in your news aggregator and for the block created for the bundle.</li>
<li><strong>Title</strong> -- The title will be used in the <em>news by topics</em> listing in your news aggregator and for the block created for the bundle.</li>
<li><strong>Description</strong> -- A short description of the category to tell users more details about what news items they might find in the category.</li>
<li><strong>Latest items block</strong> -- The number of items selected here will determine how many of the latest items from the category will appear in a block which may be enabled and placed in the <a href="%block">blocks</a> administration page.</li>
</ul>
......@@ -61,7 +61,7 @@ function aggregator_help($section) {
case 'admin/aggregator/add/feed':
return t('Add a site that has an RSS/RDF feed. The URL is the full path to the RSS feed file. For the feed to update automatically you must run "cron.php" on a regular basis. If you already have a feed with the URL you are planning to use, the system will not accept another feed with the same URL.');
case 'admin/aggregator/add/category':
return t('Categories provide a way to group items from different news feeds together. Each news category has its own feed page and block. For example, you could tag various sport-related feeds as belonging to a category called <i>Sports</i>. News items can be added to a category automatically by setting a feed to automatically place its item into that category, or by using the categorize items link in any listing of news items.');
return t('Categories provide a way to group items from different news feeds together. Each news category has its own feed page and block. For example, you could tag various sport-related feeds as belonging to a category called <em>Sports</em>. News items can be added to a category automatically by setting a feed to automatically place its item into that category, or by using the categorize items link in any listing of news items.');
case 'admin/aggregator/configure':
return t('These settings control the display of aggregated content.');
}
......
......@@ -192,12 +192,12 @@ function blog_form(&$node) {
*/
if ($nid && $blog = node_load(array('nid' => $nid))) {
$node->body = '<i>'. $blog->body .'</i> ['. l($blog->name, "node/$nid") .']';
$node->body = '<em>'. $blog->body .'</em> ['. l($blog->name, "node/$nid") .']';
}
if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.title as ftitle, f.link as flink FROM {aggregator_item} i, {aggregator_feed} f WHERE i.iid = %d AND i.fid = f.fid', $iid))) {
$node->title = $item->title;
$node->body = "<a href=\"$item->link\">$item->title</a> - <i>". $item->description ."</i> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
$node->body = "<a href=\"$item->link\">$item->title</a> - <em>". $item->description ."</em> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
}
}
......
......@@ -192,12 +192,12 @@ function blog_form(&$node) {
*/
if ($nid && $blog = node_load(array('nid' => $nid))) {
$node->body = '<i>'. $blog->body .'</i> ['. l($blog->name, "node/$nid") .']';
$node->body = '<em>'. $blog->body .'</em> ['. l($blog->name, "node/$nid") .']';
}
if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.title as ftitle, f.link as flink FROM {aggregator_item} i, {aggregator_feed} f WHERE i.iid = %d AND i.fid = f.fid', $iid))) {
$node->title = $item->title;
$node->body = "<a href=\"$item->link\">$item->title</a> - <i>". $item->description ."</i> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
$node->body = "<a href=\"$item->link\">$item->title</a> - <em>". $item->description ."</em> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
}
}
......
......@@ -22,13 +22,13 @@ function filter_help($section) {
case 'admin/filters':
return t('
<p><i>Input formats</i> define a way of processing user-supplied text in Drupal. Every input format has its own settings of which <i>filters</i> to apply. Possible filters include stripping out malicious HTML and making URLs clickable.</p>
<p><em>Input formats</em> define a way of processing user-supplied text in Drupal. Every input format has its own settings of which <em>filters</em> to apply. Possible filters include stripping out malicious HTML and making URLs clickable.</p>
<p>Users can choose between the available input formats when submitting content.</p>
<p>Below you can configure which input formats are available to which roles, as well as choose a default input format (used for imported content, for example).</p>');
case 'admin/filters/#':
return t('
<p>Every <i>filter</i> performs one particular change on the user input, for example stripping out malicious HTML or making URLs clickable. Choose which filters you want to apply to text in this input format.</p>
<p>Every <em>filter</em> performs one particular change on the user input, for example stripping out malicious HTML or making URLs clickable. Choose which filters you want to apply to text in this input format.</p>
<p>If you notice some filters are causing conflicts in the output, you can <a href="%order">rearrange them</a>.', array('%configure' => url('admin/filters/'. arg(2) .'/configure'), '%order' => url('admin/filters/'. arg(2) .'/order')));
case 'admin/filters/#/configure':
......
......@@ -22,13 +22,13 @@ function filter_help($section) {
case 'admin/filters':
return t('
<p><i>Input formats</i> define a way of processing user-supplied text in Drupal. Every input format has its own settings of which <i>filters</i> to apply. Possible filters include stripping out malicious HTML and making URLs clickable.</p>
<p><em>Input formats</em> define a way of processing user-supplied text in Drupal. Every input format has its own settings of which <em>filters</em> to apply. Possible filters include stripping out malicious HTML and making URLs clickable.</p>
<p>Users can choose between the available input formats when submitting content.</p>
<p>Below you can configure which input formats are available to which roles, as well as choose a default input format (used for imported content, for example).</p>');
case 'admin/filters/#':
return t('
<p>Every <i>filter</i> performs one particular change on the user input, for example stripping out malicious HTML or making URLs clickable. Choose which filters you want to apply to text in this input format.</p>
<p>Every <em>filter</em> performs one particular change on the user input, for example stripping out malicious HTML or making URLs clickable. Choose which filters you want to apply to text in this input format.</p>
<p>If you notice some filters are causing conflicts in the output, you can <a href="%order">rearrange them</a>.', array('%configure' => url('admin/filters/'. arg(2) .'/configure'), '%order' => url('admin/filters/'. arg(2) .'/order')));
case 'admin/filters/#/configure':
......
......@@ -10,7 +10,7 @@ function help_menu() {
'callback' => 'help_main',
'access' => user_access('access administration pages'),
'weight' => 9);
foreach (module_list() as $name) {
if (module_hook($name, 'help')) {
if (module_invoke($name, 'help', "admin/help#$name")) {
......
......@@ -10,7 +10,7 @@ function help_menu() {
'callback' => 'help_main',
'access' => user_access('access administration pages'),
'weight' => 9);
foreach (module_list() as $name) {
if (module_hook($name, 'help')) {
if (module_invoke($name, 'help', "admin/help#$name")) {
......
......@@ -13,7 +13,7 @@
// ---------------------------------------------------------------------------------
// Hook implementations (needed on all page loads)
/**
* Implementation of hook_help().
*/
......@@ -27,12 +27,12 @@ function locale_help($section = "admin/help#locale") {
case 'admin/locale/language/add':
return t("<p>You need to add all languages you would like to provide the site interface in. If you can't find the desired language in the quick add dropdown, then need to provide the proper language code yourself. The language code might be used to negotiate with browsers and present flags, so it is important to pick one that is standardised for the desired language. You can also add languages by <a href=\"%import\">importing translations</a> directly into a language not yet set up.</p>", array("%import" => url("admin/locale/language/import")));
case 'admin/locale/language/import':
return t("<p>This page allows you to import a translation provided in the gettext Portable Object (.po) format. The easiest way to get your site translated is to grab an existing Drupal translation and to import it. You can obtain translations from the <a href=\"%url\">Drupal localization page</a>.</p>", array('%url' => 'http://drupal.org/localization'));
return t("<p>This page allows you to import a translation provided in the gettext Portable Object (.po) format. The easiest way to get your site translated is to grab an existing Drupal translation and to import it. You can obtain translations from the <a href=\"%url\">Drupal localization page</a>.</p>", array('%url' => 'http://drupal.org/localization'));
case 'admin/locale/language/export':
return t("<p>This page allows you to export Drupal strings. The first option is to export a translation so it can be shared. The second option is to generate a translation template, which contains all Drupal strings, but without their translations. You can use this template to start a new translation using a specialized desktop application.</p>");
case 'admin/locale/string/search':
return t("<p>It is often more convinient to get the strings of your setup on the <a href=\"%export\">export page</a>, and start with a desktop Gettext translation editor though. Here you can search in the translated and untranslated strings, and the default English texts provided by Drupal.</p>", array("%export" => url("admin/locale/language/export")));
case 'admin/help#locale':
return t("
<p>Most programs are written and documented in English, and primarily use English to interact with users. This is also true for a great deal of web sites. However, most people are less comfortable with English than with their native language, and would prefer to use their mother tongue as much as possible. Many people love to see their web site showing a lot less English, and far more of their own language. Therefore Drupal provides a framework to setup a multi-lingual web site, or to overwrite the default English texts.</p>
......@@ -40,7 +40,7 @@ function locale_help($section = "admin/help#locale") {
<p>Whenever Drupal encounters an interface string which needs to be displayed, it tries to translate it into the currently selected language. If a translation is not available, then the string is remembered, so you can look up untranslated strings easily.</p>
<p>Drupal provides two options to translate these strings. First is the integrated web interface, where you can search for untranslated strings, and specify their translations via simple web forms. An easier, and much less time consuming method is to import translations already done for your language. This is achieved by the use of GNU gettext Portable Object files. These are editable with quite convinient desktop editors specifically architected for supporting your work with GNU Gettext files. The import feature allows you to add strings from such files into the site database. The export functionality enables you to share your translations with others, generating Portable Object files from your site strings.");
break;
// TODO: integrate a rewritten version of this help into the big help screen above
/*
"<p>To translate strings start at the <a href=\"%search\">search</a> page of the locale section in the administration pages. There you will see a list of the languages you have configured. Choose the appropriate settings and search for the strings you want to translate.</p>
......@@ -57,7 +57,7 @@ function locale_help($section = "admin/help#locale") {
<p>Once you got the appropriate PO file, all you have to do is to add the locale and upload it from the <a href=\"%addlocale\">manage locale</a> screen.</p>
<p>Note that uploading and parsing the uploaded file can take quite some time, depending on the connection to the server and the server's power.</p>
", array("%search" => url("admin/locale/string/search"), "%addlocale" => url("admin/locale/languages/add"), "%translations" => 'http://www.Drupal.org/translations/', "%handbook" => 'http://www.Drupal.org/handbook/po-files', "%gettext" => 'http://www.gnu.org/software/gettext/gettext.html'));*/
}
}
}
/**
......@@ -71,14 +71,14 @@ function locale_menu() {
// Main admin menu item
$items[] = array('path' => 'admin/locale', 'title' => t('localization'),
'callback' => 'locale_admin_manage', 'access' => $access);
// Top level tabs
$items[] = array('path' => 'admin/locale/language', 'title' => t('manage languages'),
'access' => $access, 'weight' => -10, 'type' => MENU_DEFAULT_LOCAL_TASK);
$items[] = array('path' => 'admin/locale/string/search', 'title' => t('manage strings'),
'callback' => 'locale_admin_string', 'access' => $access, 'weight' => 10,
'type' => MENU_LOCAL_TASK);
// Manage languages subtabs
$items[] = array('path' => 'admin/locale/language/overview', 'title' => t('list'),
'callback' => 'locale_admin_manage', 'access' => $access, "weight" => 0,
......@@ -92,12 +92,12 @@ function locale_menu() {
$items[] = array('path' => 'admin/locale/language/export', 'title' => t('export'),
'callback' => 'locale_admin_export', 'access' => $access, 'weight' => 20,
'type' => MENU_LOCAL_TASK);
// Language related callbacks
$items[] = array('path' => 'admin/locale/language/delete', 'title' => t('confirm'),
'callback' => 'locale_admin_manage_delete_screen', 'access' => $access,
'type' => MENU_CALLBACK);
// String related callbacks
$items[] = array('path' => 'admin/locale/string/edit', 'title' => t('edit'),
'callback' => 'locale_admin_string', 'access' => $access, 'type' => MENU_CALLBACK);
......@@ -128,7 +128,7 @@ function locale_user($type, $edit, &$user, $category = NULL) {
// ---------------------------------------------------------------------------------
// Locale core functionality (needed on all page loads)
/**
* Provides interface translation services
*
......@@ -154,7 +154,7 @@ function locale($string) {
if (isset($locale_t[$string])) {
$string = ($locale_t[$string] === TRUE ? $string : $locale_t[$string]);
}
// We don't have this translation cached, so get it from the DB
else {
$result = db_query("SELECT s.lid, t.translation FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid WHERE s.source = '%s' AND t.locale = '%s'", $string, $locale);
......@@ -165,7 +165,7 @@ function locale($string) {
$string = $trans->translation;
}
}
// Either we have no such source string, or no translation
else {
$result = db_query("SELECT lid, source FROM {locales_source} WHERE source = '%s'", $string);
......@@ -228,7 +228,7 @@ function locale_supported_languages($reset = FALSE, $getall = FALSE) {
$result = db_query('SELECT locale, name, formula, enabled FROM {locales_meta} ORDER BY isdefault DESC, enabled DESC, name ASC');
while ($row = db_fetch_object($result)) {
$all['name'][$row->locale] = $row->name;
$all['formula'][$row->locale] = $row->formula;
$all['formula'][$row->locale] = $row->formula;
if ($row->enabled) {
$enabled['name'][$row->locale] = $row->name;
$enabled['formula'][$row->locale] = $row->formula;
......@@ -292,7 +292,7 @@ function locale_admin_manage() {
}
}
break;
// Remove existing language
case t('Delete'):
$languages = locale_supported_languages(FALSE, TRUE);
......@@ -313,13 +313,13 @@ function locale_admin_manage() {
function locale_admin_manage_delete_screen() {
include_once 'includes/locale.inc';
$langcode = arg(4);
// Do not allow deletion of English locale
if ($langcode == 'en') {
drupal_goto('admin/locale/language/overview');
return;
}
// For other locales, warn user that data loss is ahead
$form = form_hidden('langcode', $langcode);
$form .= form_submit(t('Delete'));
......@@ -340,7 +340,7 @@ function locale_admin_manage_add() {
// Try to add new language
case t('Add language'):
// Check for duplicates
if (db_num_rows(db_query("SELECT locale FROM {locales_meta} WHERE locale = '%s'", $edit['langcode'])) == 0) {
if (db_num_rows(db_query("SELECT locale FROM {locales_meta} WHERE locale = '%s'", $edit['langcode'])) == 0) {
// Set language name from the available list if needed
if ($edit['langcode'] && !$edit['langname'] && isset($isocodes[$edit['langcode']])) {
......@@ -376,14 +376,14 @@ function locale_admin_import() {
$edit = &$_POST['edit'];
switch ($_POST['op']) {
case t('Import'):
// Add language, if not yet supported
$languages = locale_supported_languages(TRUE, TRUE);
if (!isset($languages['name'][$edit['langcode']])) {
$isocodes = _locale_get_iso639_list();
_locale_add_language($edit['langcode'], $isocodes[$edit['langcode']][0], FALSE);
}
// Now import strings into the language
$file = file_check_upload('file');
if ($ret = _locale_import_po($file->path, $edit['langcode'], $edit['mode']) == FALSE) {
......
......@@ -13,7 +13,7 @@
// ---------------------------------------------------------------------------------
// Hook implementations (needed on all page loads)
/**
* Implementation of hook_help().
*/
......@@ -27,12 +27,12 @@ function locale_help($section = "admin/help#locale") {
case 'admin/locale/language/add':
return t("<p>You need to add all languages you would like to provide the site interface in. If you can't find the desired language in the quick add dropdown, then need to provide the proper language code yourself. The language code might be used to negotiate with browsers and present flags, so it is important to pick one that is standardised for the desired language. You can also add languages by <a href=\"%import\">importing translations</a> directly into a language not yet set up.</p>", array("%import" => url("admin/locale/language/import")));
case 'admin/locale/language/import':
return t("<p>This page allows you to import a translation provided in the gettext Portable Object (.po) format. The easiest way to get your site translated is to grab an existing Drupal translation and to import it. You can obtain translations from the <a href=\"%url\">Drupal localization page</a>.</p>", array('%url' => 'http://drupal.org/localization'));
return t("<p>This page allows you to import a translation provided in the gettext Portable Object (.po) format. The easiest way to get your site translated is to grab an existing Drupal translation and to import it. You can obtain translations from the <a href=\"%url\">Drupal localization page</a>.</p>", array('%url' => 'http://drupal.org/localization'));
case 'admin/locale/language/export':
return t("<p>This page allows you to export Drupal strings. The first option is to export a translation so it can be shared. The second option is to generate a translation template, which contains all Drupal strings, but without their translations. You can use this template to start a new translation using a specialized desktop application.</p>");
case 'admin/locale/string/search':
return t("<p>It is often more convinient to get the strings of your setup on the <a href=\"%export\">export page</a>, and start with a desktop Gettext translation editor though. Here you can search in the translated and untranslated strings, and the default English texts provided by Drupal.</p>", array("%export" => url("admin/locale/language/export")));
case 'admin/help#locale':
return t("
<p>Most programs are written and documented in English, and primarily use English to interact with users. This is also true for a great deal of web sites. However, most people are less comfortable with English than with their native language, and would prefer to use their mother tongue as much as possible. Many people love to see their web site showing a lot less English, and far more of their own language. Therefore Drupal provides a framework to setup a multi-lingual web site, or to overwrite the default English texts.</p>
......@@ -40,7 +40,7 @@ function locale_help($section = "admin/help#locale") {
<p>Whenever Drupal encounters an interface string which needs to be displayed, it tries to translate it into the currently selected language. If a translation is not available, then the string is remembered, so you can look up untranslated strings easily.</p>
<p>Drupal provides two options to translate these strings. First is the integrated web interface, where you can search for untranslated strings, and specify their translations via simple web forms. An easier, and much less time consuming method is to import translations already done for your language. This is achieved by the use of GNU gettext Portable Object files. These are editable with quite convinient desktop editors specifically architected for supporting your work with GNU Gettext files. The import feature allows you to add strings from such files into the site database. The export functionality enables you to share your translations with others, generating Portable Object files from your site strings.");
break;
// TODO: integrate a rewritten version of this help into the big help screen above
/*
"<p>To translate strings start at the <a href=\"%search\">search</a> page of the locale section in the administration pages. There you will see a list of the languages you have configured. Choose the appropriate settings and search for the strings you want to translate.</p>
......@@ -57,7 +57,7 @@ function locale_help($section = "admin/help#locale") {
<p>Once you got the appropriate PO file, all you have to do is to add the locale and upload it from the <a href=\"%addlocale\">manage locale</a> screen.</p>
<p>Note that uploading and parsing the uploaded file can take quite some time, depending on the connection to the server and the server's power.</p>
", array("%search" => url("admin/locale/string/search"), "%addlocale" => url("admin/locale/languages/add"), "%translations" => 'http://www.Drupal.org/translations/', "%handbook" => 'http://www.Drupal.org/handbook/po-files', "%gettext" => 'http://www.gnu.org/software/gettext/gettext.html'));*/
}
}
}
/**
......@@ -71,14 +71,14 @@ function locale_menu() {
// Main admin menu item
$items[] = array('path' => 'admin/locale', 'title' => t('localization'),
'callback' => 'locale_admin_manage', 'access' => $access);
// Top level tabs
$items[] = array('path' => 'admin/locale/language', 'title' => t('manage languages'),
'access' => $access, 'weight' => -10, 'type' => MENU_DEFAULT_LOCAL_TASK);
$items[] = array('path' => 'admin/locale/string/search', 'title' => t('manage strings'),
'callback' => 'locale_admin_string', 'access' => $access, 'weight' => 10,
'type' => MENU_LOCAL_TASK);
// Manage languages subtabs
$items[] = array('path' => 'admin/locale/language/overview', 'title' => t('list'),
'callback' => 'locale_admin_manage', 'access' => $access, "weight" => 0,
......@@ -92,12 +92,12 @@ function locale_menu() {
$items[] = array('path' => 'admin/locale/language/export', 'title' => t('export'),
'callback' => 'locale_admin_export', 'access' => $access, 'weight' => 20,
'type' => MENU_LOCAL_TASK);
// Language related callbacks
$items[] = array('path' => 'admin/locale/language/delete', 'title' => t('confirm'),
'callback' => 'locale_admin_manage_delete_screen', 'access' => $access,
'type' => MENU_CALLBACK);
// String related callbacks
$items[] = array('path' => 'admin/locale/string/edit', 'title' => t('edit'),
'callback' => 'locale_admin_string', 'access' => $access, 'type' => MENU_CALLBACK);
......@@ -128,7 +128,7 @@ function locale_user($type, $edit, &$user, $category = NULL) {
// ---------------------------------------------------------------------------------
// Locale core functionality (needed on all page loads)
/**
* Provides interface translation services
*
......@@ -154,7 +154,7 @@ function locale($string) {
if (isset($locale_t[$string])) {
$string = ($locale_t[$string] === TRUE ? $string : $locale_t[$string]);
}
// We don't have this translation cached, so get it from the DB
else {
$result = db_query("SELECT s.lid, t.translation FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid WHERE s.source = '%s' AND t.locale = '%s'", $string, $locale);
......@@ -165,7 +165,7 @@ function locale($string) {
$string = $trans->translation;
}
}
// Either we have no such source string, or no translation
else {
$result = db_query("SELECT lid, source FROM {locales_source} WHERE source = '%s'", $string);
......@@ -228,7 +228,7 @@ function locale_supported_languages($reset = FALSE, $getall = FALSE) {
$result = db_query('SELECT locale, name, formula, enabled FROM {locales_meta} ORDER BY isdefault DESC, enabled DESC, name ASC');
while ($row = db_fetch_object($result)) {
$all['name'][$row->locale] = $row->name;
$all['formula'][$row->locale] = $row->formula;
$all['formula'][$row->locale] = $row->formula;
if ($row->enabled) {
$enabled['name'][$row->locale] = $row->name;
$enabled['formula'][$row->locale] = $row->formula;
......@@ -292,7 +292,7 @@ function locale_admin_manage() {
}
}
break;
// Remove existing language
case t('Delete'):
$languages = locale_supported_languages(FALSE, TRUE);
......@@ -313,13 +313,13 @@ function locale_admin_manage() {
function locale_admin_manage_delete_screen() {
include_once 'includes/locale.inc';
$langcode = arg(4);
// Do not allow deletion of English locale
if ($langcode == 'en') {
drupal_goto('admin/locale/language/overview');
return;
}
// For other locales, warn user that data loss is ahead
$form = form_hidden('langcode', $langcode);
$form .= form_submit(t('Delete'));
......@@ -340,7 +340,7 @@ function locale_admin_manage_add() {
// Try to add new language