This patch is for now a proof of concept of how to manage localizable variables, which will spawn in settngs forms allowing a different value for every language.
It is meant to be an extension of Gabor's Site settings translation with textgroups patch, but offers a slightly different approach for now. I strongly encourage to go through that patch first. This will also be rewritten and will take advantage of the new variable API if it is finally ready.

The idea:

- Site settings translation with textgroups is a good idea for 'text' variables. These will need a translator, and also they won't affect the system behaviour, so they can be made available for translators.
- There are other variables though that:

  • You may want to make localizable, this is, able to take a different value for every language. This is different from 'translatable' in that they're not user interface texts.
  • Shouldn't be edited by people without the right permissions, like 'Administer site configuration' for some of them. This is not a permission you'd like to enable for site translators, that may be not technical staff.
  • Also, they're not translatable texts, but more low level values, like a image path, or a menu.
  • Some samples of these variables are: Site front page, Primary links menu, Theme used, Logo image -when it contains text-, etc...

The solution proposed is:

  • Altering these settings forms so selected variables in settings forms may spawn to a different field for every language.
  • The site administrator can select directly on the forms, from the list of predefined variables provided by modules with 'hook_locale', which ones will be 'localized' taking a value for each language, and which ones not
  • At the low level, a language field is added to 'variables' table. This will allow to store there settings that are not 'translatable texts'.
  • The variable loading is done in three stages: first default variables, then localizable variables, then translated text variables. This shouldn't impact performance really as most of the time variables are cached.
  • There's a new 'variable_get_default' function that is meant to be used in settings forms, and that will retrieve the default value -or the value for the default language- for this variables, instead of the value for the current page language
  • The list of localizable variables is kept in a static variable. It wont be updated permanently until the form is submitted.

Example: site information form


This is the 'Default front page' field. Note the link 'make this setting localizable'.

What happens when you click on that link. Note the link 'change this setting' to get back to previous state. Currently the form is just reloaded with the field extending for each language. Some javascript or ajax may be helpful here though.

CommentFileSizeAuthor
variables_localize_00.patch38.85 KBJose Reyero
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

Status: Active » Needs review

Some notes:

1. As I have noted elsewhere, text values might as well need their corresponding form widgets to edit them properly. Like user email texts need their token help to instruct translator to use them properly. I don't see that included in this patch.
2. Although you save text variables as source text in the locales_source table, when doing a variable_sat() or variable_del(), you don't touch those tables, you seem to assert that all variables are saved in the variables table.
3. This patch includes a reverse proxy fix, which is already in Drupal 6 and is clearly not related to this issue.
4. This patch does not include DB updates, but understandably it is due to the proof-of-concept nature you mention, so it is not an issue yet.

catch’s picture

Version: 6.x-dev » 7.x-dev
Status: Needs review » Needs work

No longer applies. Not sure how much of this may have made it into D6 in other patches but bumping to D7.

Jose Reyero’s picture

Issue tags: +i18n sprint
plach’s picture

Version: 7.x-dev » 8.x-dev

I am afraid this will have to wait for D8 :(

Gábor Hojtsy’s picture

Status: Needs work » Closed (won't fix)

The variable / settings system is being totally retooled in Drupal 8 so this will not be applicable. The scope of translation support will be able to map to a wider set of use cases. Closing.