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?

Comments

For those still on D6 the solution is to use Domain i18n (http://drupal.org/project/domain_i18n)

nonsie

Nice article! I'm gonna test it soon on my new project.

batigol

Hi Jose! I truly appreciate your presentation... I am getting there finally.
question, after I followed all the steps, I got all exactly as presented except for the Domain + Language link.

what did you set up or how did you make that link show up there?
I missed something.

thank you

Virginia Hiering

For that one to show up you need to select one or more variables for both realms (Domain and Language).

Jose

Hi,
i followed your instructions, but i just cant get the links to show up in /admin/config/system/site-information

I have a 4 domains site and each of them share 3 languages (so EN - FR and IT should be available on all domains).

are there any domain or i18n modules that should NOT be activated ?

Leiv Hendrickx

There are possibly many modules that should not be activated, both packages contain a lot of them, you just don't activate modules unless you know what they are for.

Anyway, this is the kind of question to be answered in the module's issue tracker.

Jose

Thank you Jose! for all the clear instructions and sharing.
i followed all through and so far so good for a beginner that i am : )
question: i wanted for a start to have de.domain.com with 3 languages (de/sp/en), ve.domain.com (sp), defualt-domain.com (en). after following all your instructions i am ending up with 3 languages for each domain. the default and de.- will end up eventually with more languages. can i at this point delete variables like for ex. to keep ve.- with only (sp) ? i am hoping it will not be a biggy to add other languages as i expand for the future- i will appreciate any detailed respond. thank you again

Virginia Hiering

So I have everything set up, as in your "Multilingual domain variables - Variable modules" screen. The only problem is that the links for changing the current domain do nothing, I have to change the actual URL to be on the "other" site.

Any idea what could be wrong?