-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstringoverrides.module
More file actions
82 lines (74 loc) · 3.27 KB
/
stringoverrides.module
File metadata and controls
82 lines (74 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* @file
* Configuration interface to provide a quick and easy way of replacing text.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function stringoverrides_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.stringoverrides':
$output = '<p>' . t('The <strong>String Overrides</strong> module provides a quick and easy way of replacing text.') . '</p>';
$output .= '<p>' . t('To replace a string, enter <strong>the complete string</strong> that is passed through the <a href="@t">t()</a> function. String Overrides cannot translate user-defined content, it can only replace strings wrapped in the t() function. To find the strings you can actually change, open up a module and look for t() function calls. Places where %, @, or ! are used means that the translation contains dynamic information (such as the node type or title in the above examples); these are not translated while the text around them is.', array('@t' => 'http://api.drupal.org/api/function/t')) . '</p>';
// $output .= theme('item_list', array(
// 'title' => t('Examples'),
// 'items' => array(
// '"The %post has been updated." → "You just updated the %post."',
// '"Are you sure you want to delete %title?" → "Do you want to delete %title?"',
// ),
// ));
$output .= '<p>' . t('Remember, you must replace the entire string, not just a portion of it.') . '</p>';
return $output;
}
if ($path == 'admin/config/regional/stringoverrides' || strpos($path, 'admin/config/regional/stringoverrides/manage/') !== FALSE) {
$languages = language_list();
if (isset($arg[5]) && isset($languages[$arg[5]])) {
$lang = $languages[$arg[5]]->native;
return '<p>' . t('The following provides a quick and easy way of replacing text in @lang.', array('@lang' => $lang)) . '</p>';
}
return '<p>' . t('The following provides a quick and easy way of replacing text.') . '</p>';
}
}
/**
* Implements hook_menu().
*/
function stringoverrides_menu() {
// Add the language tabs if there are other languages
if (module_exists('locale')) {
global $language;
$languages = locale_language_list();
foreach ($languages as $code => $name) {
$items["admin/config/regional/stringoverrides/manage/$code"] = array(
'title' => '@lang',
'title arguments' => array('@lang' => $name),
'page arguments' => array('stringoverrides_admin', $code),
'access arguments' => array('administer string overrides'),
'type' => $language->language == $code ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
);
}
}
else {
$items['admin/config/regional/stringoverrides/manage/en'] = array(
'title' => 'Overrides',
'page callback' => 'drupal_get_form',
'page arguments' => array('stringoverrides_admin', 'en'),
'access arguments' => array('administer string overrides'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'file' => 'stringoverrides.admin.inc',
);
}
return $items;
}
/**
* Implements hook_theme().
*/
function stringoverrides_theme() {
return array(
'stringoverrides_strings' => array(
'render element' => 'form',
'file' => 'stringoverrides.admin.inc',
),
);
}