Skip to content
Snippets Groups Projects
Commit 3924c57d authored by Ryan Szrama's avatar Ryan Szrama
Browse files

Issue #1032302 by pcambra, rszrama: add title translation support via the...

Issue #1032302 by pcambra, rszrama: add title translation support via the Title module, alter untranslatable entities out of the Entity translation settings form, and fix a bug in the translation tab access callback.
parent aee34f3c
No related branches found
Tags 7.x-1.0-beta3
No related merge requests found
......@@ -378,3 +378,11 @@ function commerce_customer_ui_set_breadcrumb($profile_types = FALSE) {
drupal_set_breadcrumb($breadcrumb);
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function commerce_customer_ui_form_entity_translation_admin_form_alter(&$form, &$form_state, $form_id) {
// Hide the commerce_customer_profile option from entity translation.
unset($form['entity_translation_entity_types']['#options']['commerce_customer_profile']);
}
......@@ -95,6 +95,14 @@ function commerce_line_item_ui_form_alter(&$form, &$form_state, $form_id) {
}
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function commerce_line_item_ui_form_entity_translation_admin_form_alter(&$form, &$form_state, $form_id) {
// Hide the commerce_line_item option from entity translation.
unset($form['entity_translation_entity_types']['#options']['commerce_line_item']);
}
/**
* Implements hook_views_api().
*
......
......@@ -299,3 +299,11 @@ function commerce_order_ui_order_view($order, $view_mode = 'administrator', $bre
return commerce_order_build_content($order, $view_mode);
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function commerce_order_ui_form_entity_translation_admin_form_alter(&$form, &$form_state, $form_id) {
// Hide the commerce_order option from entity translation.
unset($form['entity_translation_entity_types']['#options']['commerce_order']);
}
......@@ -67,11 +67,34 @@ function commerce_product_entity_info() {
'deletion callback' => 'commerce_product_delete',
'access callback' => 'commerce_product_access',
'token type' => 'product',
// Add entity translation support.
'translation' => array(
'entity_translation' => array(
'class' => 'EntityTranslationCommerceProductHandler',
),
),
// Add title replacement support for translations.
'field replacement' => array(
'title' => array(
'field' => array(
'type' => 'text',
'cardinality' => 1,
'translatable' => TRUE,
),
'instance' => array(
'label' => t('Title'),
'required' => TRUE,
'settings' => array(
'text_processing' => 0,
),
'widget' => array(
'weight' => -5,
),
),
),
),
),
);
......@@ -806,10 +829,10 @@ function _commerce_product_match_products_standard($instance, $string = '', $mat
}
/**
* Access callback: determins access to a product's translation tab.
* Access callback: determines access to a product's translation tab.
*/
function commerce_product_entity_translation_tab_access($product) {
if ($product->language != LANGUAGE_NONE) {
if (!empty($product->language) && $product->language != LANGUAGE_NONE) {
if (commerce_product_entity_translation_supported_type($product->type)) {
return entity_translation_tab_access('commerce_product');
}
......
......@@ -14,6 +14,8 @@
* with only a product type defined.
*/
function commerce_product_product_form($form, &$form_state, $product) {
$language = !empty($product->language) ? $product->language : LANGUAGE_NONE;
// Ensure this include file is loaded when the form is rebuilt from the cache.
$form_state['build_info']['files']['form'] = drupal_get_path('module', 'commerce_product') . '/includes/commerce_product.forms.inc';
......@@ -40,7 +42,7 @@ function commerce_product_product_form($form, &$form_state, $product) {
// Add the field related form elements.
$form_state['commerce_product'] = $product;
field_attach_form('commerce_product', $product, $form, $form_state, $product->language);
field_attach_form('commerce_product', $product, $form, $form_state, $language);
$form['status'] = array(
'#type' => 'radios',
......@@ -64,7 +66,7 @@ function commerce_product_product_form($form, &$form_state, $product) {
// Simply use default language
$form['language'] = array(
'#type' => 'value',
'#value' => $product->language,
'#value' => $language,
);
// We add the form's #submit array to this button along with the actual submit
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment