first import

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-08 11:40:19 +02:00
commit 1bc61b12ad
8435 changed files with 1582817 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
name = User mail translation
description = "Translate emails sent from the User module."
core = 7.x
package = Multilingual - Internationalization
dependencies[] = i18n_variable
; Information added by drupal.org packaging script on 2013-01-13
version = "7.x-1.8"
core = "7.x"
project = "i18n"
datestamp = "1358075001"

View File

@@ -0,0 +1,15 @@
<?php
/**
* @file
* Installation file for User mail translation module.
*/
/**
* Implements hook_install().
*/
function i18n_user_install() {
// Set module weight for it to run before any other module implementing hook_mail_alter().
db_query("UPDATE {system} SET weight = -10000 WHERE name = 'i18n_user' AND type = 'module'");
}

View File

@@ -0,0 +1,69 @@
<?php
/**
* @file
* User mail translation module.
*/
/**
* Implements hook_mail_alter().
*/
function i18n_user_mail_alter(&$message) {
if ($message['module'] == 'user') {
$language = $message['language'];
$variables = array('user' => $message['params']['account']);
$key = $message['key'];
$components = array('subject', 'body');
foreach ($components as $component) {
$text = i18n_variable_get('user_mail_' . $key . '_' . $component, $language->language, FALSE);
if ($text) {
$text = token_replace($text, $variables, array('language' => $language, 'callback' => 'i18n_user_user_mail_tokens', 'sanitize' => FALSE));
switch ($component) {
case 'subject':
$message[$component] = $text;
break;
case 'body':
$message[$component] = array($text);
break;
}
}
}
}
}
/**
* Overrides user_mail_tokens().
*
* @see i18n_user_user_tokens_alter()
* @see user_mail_tokens()
*/
function i18n_user_user_mail_tokens(&$replacements, $data, $options) {
if (isset($data['user'])) {
$replacements['[user:one-time-login-url]'] = i18n_user_user_pass_reset_url($data['user']);
$replacements['[user:cancel-url]'] = i18n_user_user_cancel_url($data['user']);
}
}
/**
* Overrides user_pass_reset_url().
* Generates a unique and localized URL for a user to login and reset their password.
*
* @see user_pass_reset_url().
*/
function i18n_user_user_pass_reset_url($account) {
$timestamp = REQUEST_TIME;
return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE, 'language' => i18n_language($account->language)));
}
/**
* Overrides user_pass_cancel_url().
* Generates a localized URL to confirm an account cancellation request.
*
* @see i18n_user_user_cancel_url()
*/
function i18n_user_user_cancel_url($account) {
$timestamp = REQUEST_TIME;
return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE, 'language' => i18n_language($account->language)));
}