Index: l10n_client.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_client/Attic/l10n_client.info,v
retrieving revision 1.5
diff -u -p -r1.5 l10n_client.info
--- l10n_client.info 12 Mar 2009 15:29:40 -0000 1.5
+++ l10n_client.info 14 Jul 2009 17:47:44 -0000
@@ -2,5 +2,6 @@
name = Localization client
description = Provides on-page localization
dependencies[] = locale
-core = 6.x
+core = 7.x
package = Multilanguage
+files[] = l10n_client.module
Index: l10n_client.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_client/Attic/l10n_client.js,v
retrieving revision 1.10
diff -u -p -r1.10 l10n_client.js
--- l10n_client.js 15 Apr 2009 19:10:13 -0000 1.10
+++ l10n_client.js 14 Jul 2009 17:47:44 -0000
@@ -1,7 +1,9 @@
// $Id: l10n_client.js,v 1.10 2009/04/15 19:10:13 goba Exp $
+(function ($) {
+
// Store all l10n_client related data + methods in its own object
-jQuery.extend(Drupal, {
+$.extend(Drupal, {
l10nClient: new (function() {
// Set "selected" string to unselected, i.e. -1
this.selected = -1;
@@ -84,7 +86,8 @@ jQuery.extend(Drupal, {
});
// Attaches the localization editor behavior to all required fields.
-Drupal.behaviors.l10nClient = function (context) {
+Drupal.behaviors.l10nClient = {}
+Drupal.behaviors.l10nClient.attach = function (context) {
switch($.cookie('Drupal_l10n_client')) {
case '1':
@@ -149,16 +152,18 @@ Drupal.behaviors.l10nClient = function (
type: "POST",
url: $('#l10n-client-form').attr('action'),
// Send source and target strings.
- data: 'source=' + Drupal.encodeURIComponent($('#l10n-client-string-editor .source-text').text()) +
- '&target=' + Drupal.encodeURIComponent($('#l10n-client-form #edit-target').val()) +
- '&form_token=' + Drupal.encodeURIComponent($('#l10n-client-form #edit-l10n-client-form-form-token').val()),
+ data: {
+ source: $('#l10n-client-string-editor .source-text').text(),
+ target: $('#l10n-client-form #edit-target').val(),
+ 'form_token': $('#l10n-client-form #edit-l10n-client-form-form-token').val()
+ },
success: function (data) {
// Store string in local js
Drupal.l10nClient.setString(Drupal.l10nClient.selected, $('#l10n-client-form #edit-target').val());
// Figure out the display of the new translation in the selection list.
- var newTranslationDisplay = '';
var newTranslation = $('#l10n-client-form #edit-target').val();
+ var newTranslationDisplay = newTranslation;
var newTranslationStripped = newTranslation.replace(/<\/?[^<>]+>/gi, '')
.replace(/"/g, '"')
.replace(/</g, "<")
@@ -192,3 +197,5 @@ Drupal.behaviors.l10nClient = function (
});
};
+
+})(jQuery);
Index: l10n_client.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_client/Attic/l10n_client.module,v
retrieving revision 1.22
diff -u -p -r1.22 l10n_client.module
--- l10n_client.module 15 Apr 2009 19:10:13 -0000 1.22
+++ l10n_client.module 14 Jul 2009 17:47:44 -0000
@@ -45,15 +45,15 @@ function l10n_client_menu() {
);
// Direct copy of the import tab from locale module to
// make space for the "Reimport package" tab below.
- $items['admin/build/translate/import/file'] = array(
+ $items['admin/international/translate/import/file'] = array(
'title' => 'Import file',
- 'page callback' => 'locale_inc_callback',
- 'page arguments' => array('drupal_get_form', 'locale_translate_import_form'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('locale_translate_import_form'),
'access arguments' => array('translate interface'),
'weight' => -5,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
- $items['admin/build/translate/import/package'] = array(
+ $items['admin/international/translate/import/package'] = array(
'title' => 'Reimport packages',
'page callback' => 'drupal_get_form',
'page arguments' => array('l10n_client_import_package_form'),
@@ -64,15 +64,15 @@ function l10n_client_menu() {
// Direct copy of the Configure tab from locale module to
// make space for the "Localization sharing" tab below.
- $items['admin/settings/language/configure/language'] = array(
+ $items['admin/international/language/configure/language'] = array(
'title' => 'Language negotiation',
- 'page callback' => 'locale_inc_callback',
- 'page arguments' => array('drupal_get_form', 'locale_languages_configure_form'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('locale_languages_configure_form'),
'access arguments' => array('administer languages'),
'weight' => -10,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
- $items['admin/settings/language/configure/l10n_client'] = array(
+ $items['admin/international/language/configure/l10n_client'] = array(
'title' => 'Localization sharing',
'page callback' => 'drupal_get_form',
'page arguments' => array('l10n_client_settings_form'),
@@ -84,10 +84,19 @@ function l10n_client_menu() {
}
/**
- * Implementation of hook_perm().
+ * Implementation of hook_permission().
*/
-function l10n_client_perm() {
- return array('use on-page translation', 'submit translations to localization server');
+function l10n_client_permission() {
+ return array(
+ 'use on-page translation' => array(
+ 'title' => t('Use on-page translation'),
+ 'description' => t('Makes it possible to translate the Drupal interface on-page.'),
+ ),
+ 'submit translations to localization server' => array(
+ 'title' => t('Submit translations to localization server'),
+ 'description' => t('Allows users to submit translations to a remote localization server.'),
+ ),
+ );
}
/**
@@ -104,15 +113,15 @@ function l10n_client_init() {
// this point, that would normally result in all strings loaded into memory.
// That would go against our goal of displaying only strings used on the page
// and would hang browsers. Drops any string used for the page before this point.
- locale(NULL, NULL, TRUE);
- drupal_add_css(drupal_get_path('module', 'l10n_client') .'/l10n_client.css', 'module');
+ locale(NULL, NULL, NULL, TRUE);
+ drupal_add_css(drupal_get_path('module', 'l10n_client') .'/l10n_client.css');
// Add jquery cookie plugin -- this should actually belong in
// jstools (but hasn't been updated for HEAD)
- drupal_add_js(drupal_get_path('module', 'l10n_client') .'/jquery.hotkeys.js', 'module');
- drupal_add_js(drupal_get_path('module', 'l10n_client') .'/jquery.cookie.js', 'module');
- drupal_add_js(drupal_get_path('module', 'l10n_client') .'/l10n_client.js', 'module');
+ drupal_add_js(drupal_get_path('module', 'l10n_client') .'/jquery.hotkeys.js');
+ drupal_add_js(drupal_get_path('module', 'l10n_client') .'/jquery.cookie.js');
+ drupal_add_js(drupal_get_path('module', 'l10n_client') .'/l10n_client.js');
// We use textareas to be able to edit long text, which need resizing.
- drupal_add_js('misc/textarea.js', 'module');
+ drupal_add_js('misc/textarea.js');
}
}
@@ -203,9 +212,9 @@ function l10n_client_footer() {
// Include string selector on page.
$string_list = _l10n_client_string_list($l10n_strings);
// Include editing form on page.
- $l10n_form = drupal_get_form('l10n_client_form', $l10n_strings);
+ $l10n_form = drupal_render(drupal_get_form('l10n_client_form', $l10n_strings));
// Include search form on page.
- $l10n_search = drupal_get_form('l10n_client_search_form');
+ $l10n_search = drupal_render(drupal_get_form('l10n_client_search_form'));
// Generate HTML wrapper with strings data.
$l10n_dom = _l10n_client_dom_strings($l10n_strings);
@@ -278,8 +287,8 @@ function _l10n_client_page_strings() {
// If this is not the module's translation page, merge all strings used on the page.
if (arg(0) != 'locale' && is_array($locale = locale()) && isset($locale[$language->language])) {
-
- $strings = array_merge($strings, $locale[$language->language]);
+ // @todo: add actual context support.
+ $strings = array_merge($strings, $locale[$language->language]['']);
// Also select and add other strings for this path. Other users may have run
// into these strings for the same page. This might be useful in some cases
@@ -374,10 +383,10 @@ function l10n_client_form($form_id, $str
'#type' => 'submit',
);
$form['copy'] = array(
- '#value' => "",
+ '#markup' => "",
);
$form['clear'] = array(
- '#value' => "",
+ '#markup' => "",
);
return $form;
@@ -394,7 +403,7 @@ function l10n_client_search_form() {
'#type' => 'textfield',
);
$form['clear-button'] = array(
- '#value' => "",
+ '#markup' => "",
);
return $form;
}
@@ -409,7 +418,8 @@ function l10n_client_save_string() {
if (isset($_POST['source']) && isset($_POST['target']) && !empty($_POST['form_token']) && drupal_valid_token($_POST['form_token'], 'l10n_client_form')) {
include_once 'includes/locale.inc';
$report = array(0, 0, 0);
- _locale_import_one_string_db($report, $language->language, $_POST['source'], $_POST['target'], 'default', NULL, LOCALE_IMPORT_OVERWRITE);
+ // @todo: add actual context support.
+ _locale_import_one_string_db($report, $language->language, '', $_POST['source'], $_POST['target'], 'default', NULL, LOCALE_IMPORT_OVERWRITE);
cache_clear_all('locale:', 'cache', TRUE);
_locale_invalidate_js($language->language);
@@ -429,14 +439,14 @@ function l10n_client_save_string() {
* @ingroup forms
* @see l10n_client_import_package_form_submit()
*/
-function l10n_client_import_package_form(&$form_state) {
+function l10n_client_import_package_form() {
// Get all languages, except English
$names = locale_language_list('name', TRUE);
unset($names['en']);
if (!count($names)) {
// This only works if there is any foreign language set up.
- drupal_set_message(t('No languages set up to reimport packages into.', 'warning'));
+ drupal_set_message(t('No languages set up to reimport packages into.'), 'warning');
return array();
}
@@ -520,7 +530,7 @@ function l10n_client_settings_form() {
* Make sure it supports the exact version of the API we will try to use.
*/
function l10n_client_settings_form_validate($form, &$form_state) {
- if ($form_state['values']['l10n_client_use_server']) {
+ if ($form_state['values']['l10n_client_use_server'] && drupal_function_exists('xmlrpc')) {
// Try to invoke the remote string submission with a test request.
$response = xmlrpc($form_state['values']['l10n_client_server'] .'/xmlrpc.php', 'l10n.server.test', '2.0');