Answers.Body: <p>You can't get a territory name directly from a locale tag (e.g. 'en' or 'en_gb'). But what you could do is to
  take the territory part of the tag (two letter country code; <strong>keep in mind, it's optional</strong>) and get the territory
  name via <code>getTerritory</code>:</p>
  
  <pre><code>{% set locales = ['en_gb', 'fr_fr', 'zh_cn'] %}
  
  {% for locale in locales %}
  
      {% set subTags = locale|split('_') %}
  
      {% set territory = subTags|length &gt; 1 ? craft.i18n.getLocaleData(craft.locale).getTerritory(subTags|last) : '' %}
  
      {% set language = craft.i18n.getLocaleById(locale).name %}
      {% set language = language ?: craft.i18n.getLocaleById(subTags|first).name %}
      {% set language = language|replace("/- #{territory}$/", '') %}
  
      {% if territory and language %}
          &lt;li&gt;Territory: {{ territory }}, Language: {{ language }}&lt;/li&gt;
      {% endif %}
  
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-23T10:04:22.103Z
Answers.Text: Hey @carlcs, I got it tried with the code I updated the question with, but I always got only the same country, for all locales. You're right. There is no relation with locales and territories, so it's impossible yet. Thanks anyway
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-23T12:54:20.497Z
Answers.Text: No @Dominic! There actually is a relationship between locals and territories, I think you misunderstood my answer. The code works as is, so you probably didn't implemented it correctly for your needs.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-06T11:53:46.700Z
Answers.Text: Finally I got to it and have started testing. Yes, it works, It's great, except regions `en_001` etc. I get empty value for `locale`.
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-06T13:36:25.407Z
Answers.Text: @Dominik now you can go crazy and do things like 'en_001', 'hu_sk', 'de_sk' or 'tr_de'.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-06T14:30:28.223Z
Answers.Text: Love IT more! @carlcs Thank you, you good.
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-22T20:36:14.767Z
Answers.LastActivityDate: 2015-03-06T13:21:32.000Z
Answers.LastEditDate: 2015-03-06T13:21:32.000Z
Answers.UserDisplayName: carlcs
Body: <p>I'm asking, because I was trying to find out the whole afternoon. Found some posts, but they were related to getting all territories.</p>
  
  <p>Example:</p>
  
  <p>I have locales like English, French, Chinese and I'd like to add country to each related locale from territories, because each locale.php in /data folder has the values.</p>
  
  <p>So it would looks like: Territory(United Kingdom) locale(English)</p>
  
  <p>Code I'm working on:</p>
  
  <pre><code>{% set locale = craft.i18n.getCurrentLocale() %}
      {# Configure site locales #}
      {% set locales = ['en', 'en_gb', 'sk'] %}
      {# Check if locale equals the requested page locale #}
      {% if locale == craft.locale %}
          {% set current = true %}
      {% else %}
          {% set current = false %}
      {% endif %}
  
  &lt;ul&gt;
    {% for locale in locales %}
      &lt;li&gt;
        &lt;a href="{{ craft.config.siteUrl[locale] ~ craft.request.getPath() }}"&gt;
           ({{ craft.i18n.getLocaleById(locale).nativeName }})
        &lt;/a&gt;
      &lt;/li&gt;
    {% endfor %} 
  &lt;/ul&gt;
  </code></pre>
  
  <p>The output is a list of locales with native name:</p>
  
  <ul>
  <li>(English)</li>
  <li>(British English)</li>
  <li>(Slovak)</li>
  </ul>
  
  <p>If there would be a way to relate it's country to each locale from territories, that we wouldn't have to touch app folder to customize the lang files, like I read in other posts.
  By doing so, We could achieve this:</p>
  
  <ul>
  <li>World (English)</li>
  <li>United Kingdom (British English)</li>
  <li>Slovakia (Slovak)</li>
  </ul>
  
  <p><strong>Update</strong></p>
  
  <p>I think it moved on a little bit. With the code @carlcs provided, Craft was able to get a territory. There must to be some bug in it, because <strong>from 3 locales, It got assigned to only one territory</strong> (United Kingdom - British English).</p>
  
  <p>Here is updated code.</p>
  
  <pre><code> &lt;ul class="uk-nav"&gt;
   {% set locales = ['en', 'en_gb', 'sk'] %}
     {% for locale in locales %}
        {% set subTags = locale|split('_') %}
           {% set territory = subTags|length &gt; 1 ? craft.i18n.getLocaleData(craft.locale).getTerritory(subTags|last) : '' %}  
               &lt;li&gt;
                   &lt;a href="{{ craft.config.siteUrl[locale] ~ craft.request.getPath() }}" class="{{ current ? 'uk-active'}}"&gt;
                   {% if territory %}{{ territory }}{% endif %} ({{craft.i18n.getLocaleById(locale).nativeName }})
                   &lt;/a&gt;
               &lt;/li&gt;
    {% endfor %} 
    &lt;/ul&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-22T16:00:36.057Z
Comments.Text: Dominic, could you please explain a bit on what you're trying to acchive?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-22T17:45:37.523Z
Comments.Text: Yeah... not sure I'm following, either.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-02T06:16:20.763Z
Comments.Text: That's easy, Dominic. No territory part in your locale →no territory!
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-02T08:01:44.567Z
Comments.Text: @carlcs So I have to modify the files from ../i18n/data/locale.php? I'd like to avoid that if So.
Comments.UserDisplayName: Dominik Krulak
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-03T09:13:08.707Z
Comments.Text: No, use locales with territory subtags only! Example: locale `de` has no territory info (and could be spoken anywhere in the world), but `de_de` does have that secific info, it's german as it is spoken in germany. It's that simple!
Comments.UserDisplayName: carlcs
Tags: <templating><localization>
Title: Get the territory / country belonging to a locale?
ThreadText: # Get the territory / country belonging to a locale?
  
  (Asked by: username_0 on 2015-02-22)
  
  I'm asking, because I was trying to find out the whole afternoon. Found some posts, but they were related to getting all territories.
  
  Example:
  
  I have locales like English, French, Chinese and I'd like to add country to each related locale from territories, because each locale.php in /data folder has the values.
  
  So it would looks like: Territory(United Kingdom) locale(English)
  
  Code I'm working on:
  
  ```
  {% set locale = craft.i18n.getCurrentLocale() %}
      {# Configure site locales #}
      {% set locales = ['en', 'en_gb', 'sk'] %}
      {# Check if locale equals the requested page locale #}
      {% if locale == craft.locale %}
          {% set current = true %}
      {% else %}
          {% set current = false %}
      {% endif %}
  
  <ul>
    {% for locale in locales %}
      <li>
        <a href="{{ craft.config.siteUrl[locale] ~ craft.request.getPath() }}">
           ({{ craft.i18n.getLocaleById(locale).nativeName }})
        </a>
      </li>
    {% endfor %} 
  </ul>
  
  ```
  
  The output is a list of locales with native name:
  
  * (English)
  * (British English)
  * (Slovak)
  
  If there would be a way to relate it's country to each locale from territories, that we wouldn't have to touch app folder to customize the lang files, like I read in other posts.
  By doing so, We could achieve this:
  
  * World (English)
  * United Kingdom (British English)
  * Slovakia (Slovak)
  
  **Update**
  
  I think it moved on a little bit. With the code @username_1 provided, Craft was able to get a territory. There must to be some bug in it, because **from 3 locales, It got assigned to only one territory** (United Kingdom - British English).
  
  Here is updated code.
  
  ```
   <ul class="uk-nav">
   {% set locales = ['en', 'en_gb', 'sk'] %}
     {% for locale in locales %}
        {% set subTags = locale|split('_') %}
           {% set territory = subTags|length > 1 ? craft.i18n.getLocaleData(craft.locale).getTerritory(subTags|last) : '' %}  
               <li>
                   <a href="{{ craft.config.siteUrl[locale] ~ craft.request.getPath() }}" class="{{ current ? 'uk-active'}}">
                   {% if territory %}{{ territory }}{% endif %} ({{craft.i18n.getLocaleById(locale).nativeName }})
                   </a>
               </li>
    {% endfor %} 
    </ul>
  
  ```
  
  **Tags:** templating, localization
  
  > **Comments:**
  > **username_1**: Dominic, could you please explain a bit on what you're trying to acchive?  
  > **username_2**: Yeah... not sure I'm following, either.  
  > **username_1**: That's easy, Dominic. No territory part in your locale →no territory!  
  > **username_0**: @username_1 So I have to modify the files from ../i18n/data/locale.php? I'd like to avoid that if So.  
  > **username_1**: No, use locales with territory subtags only! Example: locale `de` has no territory info (and could be spoken anywhere in the world), but `de_de` does have that secific info, it's german as it is spoken in germany. It's that simple!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-02-22. Score: 3 | Accepted answer
  
  You can't get a territory name directly from a locale tag (e.g. 'en' or 'en\_gb'). But what you could do is to
  take the territory part of the tag (two letter country code; **keep in mind, it's optional**) and get the territory
  name via `getTerritory`:
  
  ```
  {% set locales = ['en_gb', 'fr_fr', 'zh_cn'] %}
  
  {% for locale in locales %}
  
      {% set subTags = locale|split('_') %}
  
      {% set territory = subTags|length > 1 ? craft.i18n.getLocaleData(craft.locale).getTerritory(subTags|last) : '' %}
  
      {% set language = craft.i18n.getLocaleById(locale).name %}
      {% set language = language ?: craft.i18n.getLocaleById(subTags|first).name %}
      {% set language = language|replace("/- #{territory}$/", '') %}
  
      {% if territory and language %}
          <li>Territory: {{ territory }}, Language: {{ language }}</li>
      {% endif %}
  
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Hey @username_1, I got it tried with the code I updated the question with, but I always got only the same country, for all locales. You're right. There is no relation with locales and territories, so it's impossible yet. Thanks anyway  
  > **username_1**: No @Dominic! There actually is a relationship between locals and territories, I think you misunderstood my answer. The code works as is, so you probably didn't implemented it correctly for your needs.  
  > **username_0**: Finally I got to it and have started testing. Yes, it works, It's great, except regions `en_001` etc. I get empty value for `locale`.  
  > **username_1**: @username_0 now you can go crazy and do things like 'en_001', 'hu_sk', 'de_sk' or 'tr_de'.  
  > **username_0**: Love IT more! @username_1 Thank you, you good.  
  
  ---
  
  