<p>Generally speaking, locales are designed to share the same templates, so craft is not necessarily looking for a <code>/template/[locale]/</code> 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.</p>

<p>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.</p>

<p><strong>Update</strong></p>

<p>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 (<code>craft/config/license.key</code>) over to 'localeA.domain.com'.</p>

<p>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.</p>

CC BY-SA 3.0
2015-04-25T16:37:22.023Z
I uploaded only files that will be overwritten. The idea behind all that is that I  wanted to avoid of loading others sites(as you said CP, sections, fields ...etc), when It's not necessary, you know... to save nature and my economy :) I would do it in domain way for each locale, but It would be too expensive.
Dominik Krulak
CC BY-SA 3.0
2015-04-25T16:42:18.163Z
So the separate installation (as you mentioned in second paragraph) for each locale is the way for subdomain.domain.com with no need to buy extra licenses for each subdomain.
Dominik Krulak
CC BY-SA 3.0
2015-04-25T16:55:53.067Z
That's my understanding—Yes.
Douglas McDonald
CC BY-SA 3.0
2015-04-25T15:58:51.410Z
2015-04-25T16:51:44.287Z
2015-04-25T16:51:44.287Z
Douglas McDonald
<p>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.</p>

<p>I'm not sure if I configured <em>general.php</em> and <em>db.php</em> correctly to get subdomain.domain.dev loaded.</p>

<p><strong>Production steps of What I did:</strong></p>

<ol>
<li><p>Set up host to point to subdomain - subdomain.craft.dev</p>

<p>Folders structure:</p>

<p><em>craft</em></p>

<p><em>craft.dev</em></p>

<p><em>subdomain.craft.dev</em></p></li>
<li><p>Created database - subdomain_dev</p></li>
<li><p>Uploaded necessary files to subdomain folder and edited one line of code</p>

<p><code>// Tell Craft to serve the subdomain content
define('CRAFT_LOCALE', 'subdomain');</code></p></li>
<li><p>Uploaded en_gb templates to <em>../craft/templates/en_gb</em>.</p>

<p>I'm not sure, If I also should edit <code>$craftPath</code> to point to templates files for <em>en_gb</em> locale.</p></li>
<li><p>Edited <em>general.php</em></p>

<p><pre><code>
// All environments
'*' => array(),
// Development environment - Locale
'craft.dev' => array( 
    'devMode' => true,
    'siteUrl' => array(
        'en' => '<a href="http://craft.dev" rel="nofollow">http://craft.dev</a>',
        'en_gb' => '<a href="http://subdomain.craft.dev" rel="nofollow">http://subdomain.craft.dev</a>'
    )
)
);</pre></code></p></li>
<li><p>Edited <em>db.php</em></p>

<pre>
<code>
// 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',
    )   
</code>
</pre></li>
</ol>

<p>Locale en_gb was also created from back-end.
When I load the <a href="http://subdomain.craft.dev" rel="nofollow">http://subdomain.craft.dev</a>, I get Twig_Error_Runtime saying, that <code>variable</code> doesn't exist.It's like templates in <em>../craft/templates/en_gb</em> wasn't found?</p>

CC BY-SA 3.0
2015-04-25T16:05:19.073Z
What are you trying to accomplish? Are you trying to create a single site with more than one locale (with shared templates and resources)? Or create entirely separate sites for each locale (nothing shared)?
Douglas McDonald
CC BY-SA 3.0
2015-04-25T16:10:07.813Z
The goal is to have separated sites for each locales by sharing the same domain. If I understand the licensing right, so I wouldn't have to buy licenses for each locale separately.
Dominik Krulak
CC BY-SA 3.0
2015-04-25T16:12:57.683Z
As far as I know you should not have to buy separate licenses. My understanding is that you can install as many version of craft as you want on the same domain (subdomains don't count). But might check with P&T to confirm.
Douglas McDonald
CC BY-SA 3.0
2015-04-25T16:16:47.587Z
When you buy your license for `domain.com`, you should be able to copy the license file over to the `subdomain.domain.com` install.
Douglas McDonald
CC BY-SA 3.0
2015-04-25T16:26:25.423Z
Thanks @Douglas McDonald. Have you already confirmed with P&T?
Dominik Krulak
CC BY-SA 3.0
2015-04-25T16:33:31.663Z
Yes. I've asked this before for my own server, as I often host development staging sites for my clients before I get a chance to set up their servers. (I.e. 'clientA.mycompany.com' and 'clientB.mycompany.com'; both of which use the license for 'mycompany.com').
Douglas McDonald
<multi-environment>
Separated DB for each locale in subdomain with no shared Craft installation
# Separated DB for each locale in subdomain with no shared Craft installation

(Asked by: username_0 on 2015-04-25)

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?

**Tags:** multi-environment
> **Comments:**
> **username_1**: What are you trying to accomplish? Are you trying to create a single site with more than one locale (with shared templates and resources)? Or create entirely separate sites for each locale (nothing shared)?  
> **username_0**: The goal is to have separated sites for each locales by sharing the same domain. If I understand the licensing right, so I wouldn't have to buy licenses for each locale separately.  
> **username_1**: As far as I know you should not have to buy separate licenses. My understanding is that you can install as many version of craft as you want on the same domain (subdomains don't count). But might check with P&T to confirm.  
> **username_1**: When you buy your license for `domain.com`, you should be able to copy the license file over to the `subdomain.domain.com` install.  
> **username_0**: Thanks @Douglas McDonald. Have you already confirmed with P&T?  
> **username_1**: Yes. I've asked this before for my own server, as I often host development staging sites for my clients before I get a chance to set up their servers. (I.e. 'clientA.mycompany.com' and 'clientB.mycompany.com'; both of which use the license for 'mycompany.com').  

---

## 1 answers

### Answer by username_1 on 2015-04-25. Score: 4 | Accepted answer

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.

> **Comments:**
> **username_0**: I uploaded only files that will be overwritten. The idea behind all that is that I  wanted to avoid of loading others sites(as you said CP, sections, fields ...etc), when It's not necessary, you know... to save nature and my economy :) I would do it in domain way for each locale, but It would be too expensive.  
> **username_0**: So the separate installation (as you mentioned in second paragraph) for each locale is the way for subdomain.domain.com with no need to buy extra licenses for each subdomain.  
> **username_1**: That's my understanding—Yes.  

---

