added string and field translation table for translators
This commit is contained in:
parent
abbcb19838
commit
ddc28956c4
@ -41,6 +41,6 @@ function materio_translator_install() {
|
|||||||
/**
|
/**
|
||||||
* Implements hook_uninstall().
|
* Implements hook_uninstall().
|
||||||
*/
|
*/
|
||||||
function materio_translator_uninstall() {
|
// function materio_translator_uninstall() {
|
||||||
variable_del('i18n_access_languages');
|
// variable_del('materio_translator_languages');
|
||||||
}
|
// }
|
||||||
|
@ -106,6 +106,42 @@ function materio_translator_permission() {
|
|||||||
'description' => t('administer user translation language access'),
|
'description' => t('administer user translation language access'),
|
||||||
'restrict access' => TRUE,
|
'restrict access' => TRUE,
|
||||||
),
|
),
|
||||||
|
'access_translations_overview' => array(
|
||||||
|
'title' => t('Access translations overview')
|
||||||
|
),
|
||||||
|
|
||||||
|
'access_translation_table_fields' => array(
|
||||||
|
'title' => t('Access translation Fields table')
|
||||||
|
),
|
||||||
|
'access_translation_table_content_type' => array(
|
||||||
|
'title' => t('Access translation Content types table')
|
||||||
|
),
|
||||||
|
'access_translation_table_menu' => array(
|
||||||
|
'title' => t('Access translation menu table')
|
||||||
|
),
|
||||||
|
'access_translation_table_taxonomy' => array(
|
||||||
|
'title' => t('Access translation taxonomy table')
|
||||||
|
),
|
||||||
|
|
||||||
|
'translate_strings' => array(
|
||||||
|
'title' => t('Translate strings')
|
||||||
|
),
|
||||||
|
'delete_strings' => array(
|
||||||
|
'title' => t('Delete strings')
|
||||||
|
),
|
||||||
|
'refresh_strings' => array(
|
||||||
|
'title' => t('Refresh strings')
|
||||||
|
),
|
||||||
|
|
||||||
|
'import_translations' => array(
|
||||||
|
'title' => t('Import translations')
|
||||||
|
),
|
||||||
|
'export_translations' => array(
|
||||||
|
'title' => t('Import translations')
|
||||||
|
),
|
||||||
|
'update_modules_translations' => array(
|
||||||
|
'title' => t('Update modules translations')
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,25 +149,63 @@ function materio_translator_permission() {
|
|||||||
* Implements hook_form_alter().
|
* Implements hook_form_alter().
|
||||||
*/
|
*/
|
||||||
function materio_translator_form_alter(&$form, &$form_state, $form_id) {
|
function materio_translator_form_alter(&$form, &$form_state, $form_id) {
|
||||||
// Add materio_translator things to user/edit /user/add
|
// dsm($form_id);
|
||||||
if ($form_id == 'user_register_form' || $form_id == 'user_profile_form' ) {
|
|
||||||
// dsm($form_id, 'form_id');
|
|
||||||
// dsm($form, 'form');
|
|
||||||
// dsm($form_state, 'form_state');
|
|
||||||
|
|
||||||
$form['materio_translator'] = array(
|
// Add materio_translator things to user/edit /user/add
|
||||||
'#type' => 'fieldset',
|
if ($form_id == 'user_register_form' || $form_id == 'user_profile_form' ) {
|
||||||
'#title' => t('Translation access'),
|
// dsm($form_id, 'form_id');
|
||||||
'#tree' => 0,
|
// dsm($form, 'form');
|
||||||
'#access' => user_access('administer user translation language access'),
|
// dsm($form_state, 'form_state');
|
||||||
);
|
|
||||||
$form['materio_translator']['materio_translator'] = array(
|
$form['materio_translator'] = array(
|
||||||
'#type' => 'checkboxes',
|
'#type' => 'fieldset',
|
||||||
'#options' => array(LANGUAGE_NONE => t('Language neutral')) + locale_language_list('name'),
|
'#title' => t('Translation access'),
|
||||||
'#default_value' => materio_translator_load_permissions($form['#user']->uid),
|
'#tree' => 0,
|
||||||
'#description' => t('The user get edit, delete access to all content which are in this enabled languages. Create, view access needs a different access level.'),
|
'#access' => user_access('administer user translation language access'),
|
||||||
);
|
);
|
||||||
|
$form['materio_translator']['materio_translator'] = array(
|
||||||
|
'#type' => 'checkboxes',
|
||||||
|
'#options' => array(LANGUAGE_NONE => t('Language neutral')) + locale_language_list('name'),
|
||||||
|
'#default_value' => materio_translator_load_permissions($form['#user']->uid),
|
||||||
|
'#description' => t('The user get edit, delete access to all content which are in this enabled languages. Create, view access needs a different access level.'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// limit fields in string translation
|
||||||
|
if($form_id == 'i18n_string_locale_translate_edit_form'){
|
||||||
|
// dsm($form, 'form');
|
||||||
|
// dsm($form_state, 'form_state');
|
||||||
|
global $user;
|
||||||
|
$perms = materio_translator_load_permissions($user->uid);
|
||||||
|
// dsm($perms);
|
||||||
|
foreach ($form['translations'] as $langcode => $item) {
|
||||||
|
// disable field if langcode not in perms
|
||||||
|
if(!in_array($langcode, $perms) && isset($form['translations'][$langcode])){
|
||||||
|
$form['translations'][$langcode]['#disabled'] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// limit fields in string translation
|
||||||
|
if($form_id == 'field_translation_table_form'
|
||||||
|
|| $form_id == "node_translation_table_nodetype_form"
|
||||||
|
|| $form_id == "menu_translation_table_menu_form"
|
||||||
|
|| $form_id == "taxonomy_translation_table_taxonomy_form"){
|
||||||
|
// dsm($form, 'form');
|
||||||
|
// dsm($form_state, 'form_state');
|
||||||
|
global $user;
|
||||||
|
$perms = materio_translator_load_permissions($user->uid);
|
||||||
|
// dsm($perms);
|
||||||
|
foreach ($form['filtered_form']['strings'] as $id => $row) {
|
||||||
|
foreach ($row as $langcode => $field) {
|
||||||
|
// disable field if langcode not in perms
|
||||||
|
if(!in_array($langcode, $perms)){
|
||||||
|
$form['filtered_form']['strings'][$id][$langcode]['#disabled'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -224,10 +298,45 @@ function materio_translator_menu_alter(&$items) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// translation add link
|
// translation add link
|
||||||
if(preg_match('/^node\/%node\/edit\/add\/%entity_translation_language/', $path)){
|
// if(preg_match('/^node\/%node\/edit\/add\/%entity_translation_language/', $path)){
|
||||||
// dsm($item, $path);
|
// dsm($item, $path);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// translation add link
|
||||||
|
if(preg_match('/admin\/config\/regional\/translate/', $path)){
|
||||||
|
$items[$path]['access arguments'] = array('access_translations_overview');
|
||||||
}
|
}
|
||||||
|
if(preg_match('/admin\/config\/regional\/translate\/table/', $path)){
|
||||||
|
$items[$path]['access arguments'] = array('access_translation_table_fields');
|
||||||
|
}
|
||||||
|
if(preg_match('/admin\/config\/regional\/translate\/table\/nodetype/', $path)){
|
||||||
|
$items[$path]['access arguments'] = array('access_translation_table_content_type');
|
||||||
|
}
|
||||||
|
if(preg_match('/admin\/config\/regional\/translate\/table\/menu/', $path)){
|
||||||
|
$items[$path]['access arguments'] = array('access_translation_table_menu');
|
||||||
|
}
|
||||||
|
if(preg_match('/admin\/config\/regional\/translate\/table\/taxonomy/', $path)){
|
||||||
|
$items[$path]['access arguments'] = array('access_translation_table_taxonomy');
|
||||||
|
}
|
||||||
|
if(preg_match('/admin\/config\/regional\/translate\/translate/', $path)){
|
||||||
|
$items[$path]['access arguments'] = array('translate_strings');
|
||||||
|
}
|
||||||
|
if(preg_match('/admin\/config\/regional\/translate\/import/', $path)){
|
||||||
|
$items[$path]['access arguments'] = array('import_translations');
|
||||||
|
}
|
||||||
|
if(preg_match('/admin\/config\/regional\/translate\/i18n_string/', $path)){
|
||||||
|
$items[$path]['access arguments'] = array('refresh_strings');
|
||||||
|
}
|
||||||
|
if(preg_match('/admin\/config\/regional\/translate\/update/', $path)){
|
||||||
|
$items[$path]['access arguments'] = array('update_modules_translations');
|
||||||
|
}
|
||||||
|
if(preg_match('/admin\/config\/regional\/translate\/export/', $path)){
|
||||||
|
$items[$path]['access arguments'] = array('export_translations');
|
||||||
|
}
|
||||||
|
if(preg_match('/admin\/config\/regional\/translate\/delete/', $path)){
|
||||||
|
$items[$path]['access arguments'] += array("delete_strings");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,7 +539,7 @@ function _materio_translator_form_node_form_alter($form, &$form_state) {
|
|||||||
|
|
||||||
function materio_translator_node_tab_access(){
|
function materio_translator_node_tab_access(){
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
dsm($args, '1 -- materio_translator_node_tab_access args');
|
// dsm($args, '1 -- materio_translator_node_tab_access args');
|
||||||
|
|
||||||
// dsm($entity_type, "entity_type");
|
// dsm($entity_type, "entity_type");
|
||||||
// dsm($entity, "entity");
|
// dsm($entity, "entity");
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
name = Translate Perms
|
|
||||||
description = "The description of this module"
|
|
||||||
|
|
||||||
; Core version (required)
|
|
||||||
core = 7.x
|
|
||||||
|
|
||||||
; Package name (see http://drupal.org/node/542202 for a list of names)
|
|
||||||
; package =
|
|
||||||
|
|
||||||
; PHP version requirement (optional)
|
|
||||||
; php = 5.2
|
|
||||||
|
|
||||||
; Loadable code files
|
|
||||||
; files[] = translate_perms.module
|
|
||||||
; files[] = translate_perms.admin.inc
|
|
||||||
; files[] = translate_perms.class.inc
|
|
||||||
|
|
||||||
; Module dependencies
|
|
||||||
; dependencies[] = mymodule
|
|
||||||
; dependencies[] = theirmodule (1.2)
|
|
||||||
; dependencies[] = anothermodule (>=2.4)
|
|
||||||
; dependencies[] = views (3.x)
|
|
||||||
|
|
||||||
; Configuration page
|
|
||||||
; configure = admin/config/translate_perms
|
|
||||||
|
|
||||||
|
|
||||||
; For further information about configuration options, see
|
|
||||||
; - http://drupal.org/node/542202
|
|
@ -1,92 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* This is the file description for Translate Perms module.
|
|
||||||
*
|
|
||||||
* In this more verbose, multi-line description, you can specify what this
|
|
||||||
* file does exactly. Make sure to wrap your documentation in column 78 so
|
|
||||||
* that the file can be displayed nicely in default-sized consoles.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements hook_permission().
|
|
||||||
*/
|
|
||||||
function translate_perms_permission() {
|
|
||||||
return array(
|
|
||||||
'access_translations_overview' => array(
|
|
||||||
'title' => t('Access translations overview')
|
|
||||||
),
|
|
||||||
|
|
||||||
'access_translation_table_fields' => array(
|
|
||||||
'title' => t('Access translation Fields table')
|
|
||||||
),
|
|
||||||
'access_translation_table_content_type' => array(
|
|
||||||
'title' => t('Access translation Content types table')
|
|
||||||
),
|
|
||||||
'access_translation_table_menu' => array(
|
|
||||||
'title' => t('Access translation menu table')
|
|
||||||
),
|
|
||||||
'access_translation_table_taxonomy' => array(
|
|
||||||
'title' => t('Access translation taxonomy table')
|
|
||||||
),
|
|
||||||
|
|
||||||
'translate_strings' => array(
|
|
||||||
'title' => t('Translate strings')
|
|
||||||
),
|
|
||||||
'import_translations' => array(
|
|
||||||
'title' => t('Import translations')
|
|
||||||
),
|
|
||||||
'refresh_strings' => array(
|
|
||||||
'title' => t('Refresh strings')
|
|
||||||
),
|
|
||||||
'update_modules_translations' => array(
|
|
||||||
'title' => t('Update modules translations')
|
|
||||||
),
|
|
||||||
'export_translations' => array(
|
|
||||||
'title' => t('Import translations')
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements hook_menu_alter().
|
|
||||||
*/
|
|
||||||
function translate_perms_menu_alter(&$items) {
|
|
||||||
|
|
||||||
if(isset($items['admin/config/regional/translate']))
|
|
||||||
$items['admin/config/regional/translate']['access arguments'] = array('access_translations_overview');
|
|
||||||
|
|
||||||
|
|
||||||
if(isset($items['admin/config/regional/translate/table']))
|
|
||||||
$items['admin/config/regional/translate/table']['access arguments'] = array('access_translation_table_fields');
|
|
||||||
|
|
||||||
if(isset($items['admin/config/regional/translate/table/nodetype']))
|
|
||||||
$items['admin/config/regional/translate/table/nodetype']['access arguments'] = array('access_translation_table_content_type');
|
|
||||||
|
|
||||||
if(isset($items['admin/config/regional/translate/table/menu']))
|
|
||||||
$items['admin/config/regional/translate/table/menu']['access arguments'] = array('access_translation_table_menu');
|
|
||||||
|
|
||||||
if(isset($items['admin/config/regional/translate/table/taxonomy']))
|
|
||||||
$items['admin/config/regional/translate/table/taxonomy']['access arguments'] = array('access_translation_table_taxonomy');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(isset($items['admin/config/regional/translate/translate']))
|
|
||||||
$items['admin/config/regional/translate/translate']['access arguments'] = array('translate_strings');
|
|
||||||
|
|
||||||
if(isset($items['admin/config/regional/translate/import']))
|
|
||||||
$items['admin/config/regional/translate/import']['access arguments'] = array('import_translations');
|
|
||||||
|
|
||||||
if(isset($items['admin/config/regional/translate/i18n_string']))
|
|
||||||
$items['admin/config/regional/translate/i18n_string']['access arguments'] = array('refresh_strings');
|
|
||||||
|
|
||||||
if(isset($items['admin/config/regional/translate/update']))
|
|
||||||
$items['admin/config/regional/translate/update']['access arguments'] = array('update_modules_translations');
|
|
||||||
|
|
||||||
if(isset($items['admin/config/regional/translate/export']))
|
|
||||||
$items['admin/config/regional/translate/export']['access arguments'] = array('export_translations');
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -64,7 +64,7 @@ select.form-select:disabled {
|
|||||||
border-width: 0px;
|
border-width: 0px;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-color: none;
|
border-color: none;
|
||||||
background: #fff;
|
background: #f0f0f0;
|
||||||
color: #1A1A1A;
|
color: #1A1A1A;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
@ -84,6 +84,17 @@ select.form-select:focus:disabled {
|
|||||||
border-color: #fff;
|
border-color: #fff;
|
||||||
box-shadow: #fff 0 0 0px;
|
box-shadow: #fff 0 0 0px;
|
||||||
}
|
}
|
||||||
|
#i18n-string-locale-translate-edit-form {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
#i18n-string-locale-translate-edit-form #edit-original {
|
||||||
|
font-size: 1.2em;
|
||||||
|
border-bottom: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
#i18n-string-locale-translate-edit-form .form-item.form-type-textarea {
|
||||||
|
width: 24%;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
span.autocomplete-deluxe-button {
|
span.autocomplete-deluxe-button {
|
||||||
top: 0.25em;
|
top: 0.25em;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ select.form-select:disabled{
|
|||||||
border-width:0px;
|
border-width:0px;
|
||||||
border-style:solid;
|
border-style:solid;
|
||||||
border-color:none;
|
border-color:none;
|
||||||
background:#fff;
|
background:#f0f0f0;
|
||||||
color:#1A1A1A;
|
color:#1A1A1A;
|
||||||
max-width:100%;
|
max-width:100%;
|
||||||
}
|
}
|
||||||
@ -89,6 +89,17 @@ select.form-select:focus:disabled{
|
|||||||
box-shadow: #fff 0 0 0px;
|
box-shadow: #fff 0 0 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#i18n-string-locale-translate-edit-form{
|
||||||
|
position: relative;
|
||||||
|
#edit-original{
|
||||||
|
font-size: 1.2em;
|
||||||
|
border-bottom: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
.form-item.form-type-textarea{
|
||||||
|
width:24%; display: inline-block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
span.autocomplete-deluxe-button{top:0.25em;}
|
span.autocomplete-deluxe-button{top:0.25em;}
|
||||||
|
|
||||||
|
@ -223,3 +223,74 @@ function guibik_field_widget_form_alter(&$element, &$form_state, $context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Theme function for the translation table.
|
||||||
|
*
|
||||||
|
* @ingroup themeable
|
||||||
|
*/
|
||||||
|
function guibik_translation_table($variables) {
|
||||||
|
$form = $variables['form'];
|
||||||
|
$rows = array();
|
||||||
|
$header = $form['header']['#value'];
|
||||||
|
$languages = $form['languages']['#value'];
|
||||||
|
|
||||||
|
foreach (element_children($form['strings']) as $key) {
|
||||||
|
// Build the table row.
|
||||||
|
$row = array();
|
||||||
|
$row['data'][] = array('data' => drupal_render($form['strings'][$key]['source']), 'class' => 'translation-source');
|
||||||
|
|
||||||
|
foreach ($languages as $lang_code => $lang_name) {
|
||||||
|
$row['data'][] = array('data' => drupal_render($form['strings'][$key][$lang_code]), 'class' => 'translation-'. $lang_code);
|
||||||
|
};
|
||||||
|
$location = explode(':', $form['strings'][$key]['location']['#value']);
|
||||||
|
if (count($location) == 4) {
|
||||||
|
switch ($location[1]) {
|
||||||
|
case 'term':
|
||||||
|
$row['data'][] = l(t('Edit source'), 'admin/content/taxonomy/edit/term/'. $location[1], array('attributes' => array('title' => t('Edit term (@property)', array('@property' => t($location[2]))))));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'vocabulary':
|
||||||
|
$row['data'][] = l(t('Edit source'), 'admin/content/taxonomy/edit/vocabulary/'. $location[1], array('attributes' => array('title' => t('Edit vocabulary (@property)', array('@property' => t($location[2]))))));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'item':
|
||||||
|
$row['data'][] = l(t('Edit source'), 'admin/build/menu/item/'. $location[1] .'/edit', array('attributes' => array('title' => t('Edit menu item (@property)', array('@property' => t($location[2]))))));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'type':
|
||||||
|
$node_types = node_type_get_names();
|
||||||
|
$node_type = isset($node_types[$location[1]]) ? $node_types[$location[1]] : $location[1];
|
||||||
|
$row['data'][] = l(t('Edit source'), 'admin/content/node-type/'. $location[1], array('attributes' => array('title' => t('Edit @node_type (@property)', array('@node_type' => $node_type, '@property' => t($location[2]))))));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$row['data'][] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$row['data'][] = '';
|
||||||
|
}
|
||||||
|
$row['data'][] = l(t('Translate'), 'admin/config/regional/translate/edit/'. $key);
|
||||||
|
if(user_access('delete_strings'))
|
||||||
|
$row['data'][] = l(t('Delete string'), 'admin/config/regional/translate/delete/'. $key);
|
||||||
|
|
||||||
|
$rows[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = theme('table', array(
|
||||||
|
'header' => $header,
|
||||||
|
'rows' => $rows,
|
||||||
|
'attributes' => array('id' => 'translation-table')
|
||||||
|
));
|
||||||
|
|
||||||
|
if ($form['pager']['#markup']) {
|
||||||
|
$output .= drupal_render($form['pager']);
|
||||||
|
}
|
||||||
|
$output .= drupal_render_children($form);
|
||||||
|
|
||||||
|
drupal_add_css(drupal_get_path('module', 'translation_table') .'/css/translation-table-admin.css');
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user