Drupal Internationalization + Domain Access - Multilingual Variables for each Domain

There are a lot of modules for Drupal. One of them, Domain Access, enables multiple different domains on a single Drupal site and allows setting different variable values for each domain. Another of them, Internationalization, allows different variable values for each language. What was missing was a mechanism to handle that variables consistently and then allowing to mix these two 'variable realms' setting specific values for specific combinations of Domain and Language.

That is possible now with Domain Variable module which, building on the Variable module API, the Domain Access module and the Internationalization module provides support for all possible combinations of languages and domains for your variables. We are going to see how we can set up different variable values for each domain and for each language or for each combination of domain and language.

Multilingual domain variables - Variable modules

Screenshot - Settings form with domains and languages

Screenshot - Drupal Variable modules

We are going to need some basic modules of the Variable collection and the Variable Admin module just to be able to see some more details.

Multilingual domain variables - Enable modules

Screenshot - Modules from Drupal Domain Access package.

First of all we need to download and install the modules from Variable, Domain Access and Internationalization packages. Enable Domain+i18n variables integration and it will take care of all the dependencies. The Variable Admin module is needed only if you want to see some additional pages at the end.

Multilingual domain variables - Select domain variables

Screenshot - Selecting domain dependent variables

We can select the variables to be edited for each domain. This feature is provided by the Variable Domain module in combination with the Variable Realm API. Once you select the variables you can set a different value for them for each of your domains.

Multilingual domain variables - Select translatable variables

Using the Internationalization module we select the variables that we want to be multilingual. Note we are selecting some new variables but also one variable that we selected before to be editable for each domain, Site name. What will happen with these variables? Read on.

Multilingual domain variables - Here's your settings form

Drupal Screenshot - Settings forms with mixed realms

And here is the settings form on which we can set values to selected variables for each realm and for each language. The 'Realm selectors' at the top allow choosing any combination of Domain x Language. Some variables will only change per Language, some per Domain but the one we have selected for both can get a value for each Domain x Language combination. This form is auto-generated by the Variable realm module.

Multilingual domain variables - Metadata for mixed realms

Screenshot - Drupal Variable administration for mixed realms

For the Language + Domain realm we can see also which variables are defined (the ones that are set for both of the realms) and all the possible key combinations. For each key combination we can set a different value for the variables.

Multilingual domain variables - Variable realm metadata

Screenshot - Drupal Variable realm metadata

We also can see, for each enabled Variable realm, all the key combinations, which variables are defined, etc..

Multilingual domain variables - Variable realm administration

Screenshot - Variable realm administration overview

This is what we see with Variable Admin module that we don't really need for this experiment but for administration / development purposes. Variable administration if enabled provides way more information about variables and defined variable realms thatn what you can see on your settings forms.

Multilingual domain variables - Edit variables for a realm.

Screenshot - Drupal Variable administration, edit realm variables

We can also see the advanced Variable realm settings form, which is completely autogenerated (depending on the variables you have selected before) and allows edition of variables for a single realm. Ever wanted to edit all your multilingual variables together?

Update 2015-03-13: As mentioned on the comments, you need to disable the 'Domain Settings' module for the variables to show on settings forms.