Answers.Body: <p>Looks like Yii doesn't expose a way to grab all of the territories for a given locale by default.</p>
  
  <p>I've just added it to Craft 2.2, though.  So when that comes out, you'll be able to do this:</p>
  
  <pre><code>$localeData = craft()-&gt;i18n-&gt;getLocaleData('en_us');
  $allTerritories = $localeData-&gt;getAllTerritories();
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-11T06:57:50.680Z
Answers.Text: Not exactly. With your code I get a list of all locales but not of all territories (array) in craft/app/framework/i18n/data/en.php. Another question: Is there a page in the documentation where I can find an overview about all craft.i18n.* methods?
Answers.UserDisplayName: Christian Steger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-11T15:34:20.533Z
Answers.Text: Ahh, misunderstood the question. Do you want to list the territories array for each locale in craft/app/framework/i18n/data or just en.php?  We don't have craft.i18n documented yet, but we should have something for you sooner than later.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-11T16:55:42.350Z
Answers.Text: I need the territories only from one locale (en.php). I use the list in a select in a contact form.
Answers.UserDisplayName: Christian Steger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-03T12:35:02.757Z
Answers.Text: With Craft 2.2 I can output the values but not the corresponding keys. I get "146, Italy" instead of "it, Italy". The keys are consecutive numbers not country codes like de, it, en...
Answers.UserDisplayName: Christian Steger
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-24T14:53:17.420Z
Answers.Text: It doesn't look like territories is included in craft 3 i18n, right?
Answers.UserDisplayName: Toby Stokes
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-10T23:15:59.643Z
Answers.LastActivityDate: 2014-08-11T17:39:07.500Z
Answers.LastEditDate: 2014-08-11T17:39:07.500Z
Answers.UserDisplayName: Brad Bell
Body: <p>I found this code in the <a href="http://buildwithcraft.com/help/locale-data-from-templates" rel="nofollow">Craft documentation</a>:</p>
  
  <pre>
  {% set localeData = craft.i18n.getLocaleData() %}
  {% for month in localeData.getMonthNames() %}
      {{ month }}
  {% endfor %}
  </pre>
  
  <p>What I need is the whole list of countries (from Ascension Island to Zimbabwe).
  I tried <code>.getTerritories()</code> but it doesn't exist:</p>
  
  <pre>
  {% set localeData = craft.i18n.getLocaleData() %}
  {% for country in localeData.getTerritories() %}
      {{ country }}
  {% endfor %}
  </pre>
  
  <p>Is there any solution?</p>
  
Tags: <localization>
Title: How can I output the territories array with craft.i18n?
ThreadText: # How can I output the territories array with craft.i18n?
  
  (Asked by: username_0 on 2014-08-10)
  
  I found this code in the [Craft documentation](http://buildwithcraft.com/help/locale-data-from-templates):
  
  ```
  
  {% set localeData = craft.i18n.getLocaleData() %}
  {% for month in localeData.getMonthNames() %}
      {{ month }}
  {% endfor %}
  
  ```
  
  What I need is the whole list of countries (from Ascension Island to Zimbabwe).
  I tried `.getTerritories()` but it doesn't exist:
  
  ```
  
  {% set localeData = craft.i18n.getLocaleData() %}
  {% for country in localeData.getTerritories() %}
      {{ country }}
  {% endfor %}
  
  ```
  
  Is there any solution?
  
  **Tags:** localization
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-08-10. Score: 2 | Accepted answer
  
  Looks like Yii doesn't expose a way to grab all of the territories for a given locale by default.
  
  I've just added it to Craft 2.2, though. So when that comes out, you'll be able to do this:
  
  ```
  $localeData = craft()->i18n->getLocaleData('en_us');
  $allTerritories = $localeData->getAllTerritories();
  
  ```
  
  > **Comments:**
  > **username_0**: Not exactly. With your code I get a list of all locales but not of all territories (array) in craft/app/framework/i18n/data/en.php. Another question: Is there a page in the documentation where I can find an overview about all craft.i18n.* methods?  
  > **username_1**: Ahh, misunderstood the question. Do you want to list the territories array for each locale in craft/app/framework/i18n/data or just en.php?  We don't have craft.i18n documented yet, but we should have something for you sooner than later.  
  > **username_0**: I need the territories only from one locale (en.php). I use the list in a select in a contact form.  
  > **username_0**: With Craft 2.2 I can output the values but not the corresponding keys. I get "146, Italy" instead of "it, Italy". The keys are consecutive numbers not country codes like de, it, en...  
  > **username_2**: It doesn't look like territories is included in craft 3 i18n, right?  
  
  ---
  
  