Closed (duplicate)
Project:
Variable
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
3 Feb 2012 at 12:33 UTC
Updated:
28 Jun 2012 at 16:46 UTC
I am working on a module that has a per content type setting and I want that to be translatable using this module. I have defined all of the variables as per documentation but I cannot get the option to translate them.
here is what I have so far:
/**
* Implements hook_variable_info().
*/
function csm_variable_info($options) {
$variable['csm_create_[node_type]'] = array(
'title' => t('Create status message', array(), $options),
'description' => t('Create status message.', array(), $options),
'type' => 'multiple',
'repeat' => array(
'default' => t('[node:content-type:name] <em>[node:title]</em> has been createdd.', array(), $options),
'type' => 'string',
),
);
return $variable;
}
/**
* Implements hook_variable_type_info()
*/
function csm_variable_type_info() {
$type['node_type'] = array(
'title' => t('Node type'),
'options callback' => 'node_type_get_names',
'type' => 'select',
);
return $type;
}
This will change a bit but only to give you an idea.
I see the variable on the variable translation screen and I also see it in the variables admin but either way, I can't get it to be multilingual even if I configured it to be by checking the box next to it on the multilingual variables configuration.
What am I missing?
Comments
Comment #1
hanoiiComment #2
jose reyero commentedI don't know whether this will work but here are some clues:
- You don't need to define'node_type' variable type as it is already defined in includes/node.variable.inc
- You need to mark the variable as 'localize' => TRUE in hook_variable_info()
- The variable values don't have token replacement, you may need to provide a 'build callback'
Still I don't think the content type form is supported by the i18n_variable module so we may need a better UI for setting these values.
Comment #3
jose reyero commentedSee #1601950: Add support for content type settings forms.
Comment #4
joostpluijmers commentedI was bashing my head on the desk as well trying to solve a similar issue. My wish was to localize and integrate the "Available menus" in the node type settings page. I quikly found out that variable module only hooks in on forms containing the 'system_settings_form_submit' handler. The second issue and I think the reasoning behind why the variable module doesn't hook on other forms is that the variable name has to match the form field name.
I solved my problem by writing a small headless utilities module:
utilities.variables.inc:
utilities.module
Ps. Jose Reyero I would like to express my gratitude to you for your work on the variable module. I recently started upgrading my commercial clients to Drupal 7 and I am certainly loving the new variables!