Separated DB for each locale in subdomain with no shared Craft installation The goal is to have single site (subdomain.domain.dev) with single locale(en_gb) in it and with one craft installation shared with this site only.

I'm not sure if I configured general.php and db.php correctly to get subdomain.domain.dev loaded.

Production steps of What I did:


Set up host to point to subdomain - subdomain.craft.dev

Folders structure:

craft

craft.dev

subdomain.craft.dev
Created database - subdomain_dev
Uploaded necessary files to subdomain folder and edited one line of code

// Tell Craft to serve the subdomain content
define('CRAFT_LOCALE', 'subdomain');
Uploaded en_gb templates to ../craft/templates/en_gb.

I'm not sure, If I also should edit $craftPath to point to templates files for en_gb locale.
Edited general.php


// All environments
'*' => array(),
// Development environment - Locale
'craft.dev' => array( 
    'devMode' => true,
    'siteUrl' => array(
        'en' => 'http://craft.dev',
        'en_gb' => 'http://subdomain.craft.dev'
    )
)
);
Edited db.php



// All environments
'*' => array(
    'tablePrefix' => 'craft',
),

// Development environment - Locale
'craft.dev' => array(
    'server' => 'localhost',
    'user' => 'root',
    'password' => '********',
    'database' => 'craft_dev',
    ),
// Development environment - Locale
'subdomain.craft.dev' => array(
    'server' => 'localhost',
    'user' => 'root',
    'password' => '********',
    'database' => 'subdomain_dev',
    )   




Locale en_gb was also created from back-end.
When I load the http://subdomain.craft.dev, I get Twig_Error_Runtime saying, that variable doesn't exist.It's like templates in ../craft/templates/en_gb wasn't found?
Generally speaking, locales are designed to share the same templates, so craft is not necessarily looking for a /template/[locale]/ folder to find the correct templates to load. You may have to specify the different locale template paths as part of your section settings in that locales database. As far as I know the only automatic locale routing happens in your public folder, if craft is trying to resolve a route for a static page.

I'm curious as to why you would want to point the different locales to different databases? Keep in mind that structure and data are both stored in the craft database, so if you point 'locale1' at 'db1', and 'locale2' at 'db2', you are essentially loading two entirely separate sites (with their own CP, users, sections, fields, etc). This might make sense if you want to share templates and resources between the two sites. However, if you are also not sharing templates, then it might make more sense to just create two separate installations of craft.

Update

Regarding licensing and subdomains. My understanding is that you can use the same craft license on more than one craft install as long as they share the same primary domain (subdomains are ok). In your case you would set up your local dev environment to be something like: 'project.craft.dev' and 'localeA.project.craft.dev'; and the production environment to be 'domain.com' and 'localeA.domain.com'. You can then purchase the license on 'domain.com' and copy the license file (craft/config/license.key) over to 'localeA.domain.com'.

This is presuming of course that they share the same primary domain. What you can NOT do is create 'domain-localeA.com' and 'domain-localeB.com' using the same license.