<p>The <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/resources/js/craft.js#L4138" rel="nofollow"><code>BaseElementSelectorModal</code></a> class takes a second parameter <code>settings</code>, which can include a <code>criteria</code> object. This <code>criteria</code> object is used to create an <a href="https://buildwithcraft.com/classreference/models/ElementCriteriaModel" rel="nofollow">ElementCriteriaModel</a> on the server, which means it can have any property an ElementCriteriaModel can have – including <code>locale</code>:</p>

<pre><code>var currentLocale = Craft.getLocalStorage('BaseElementIndex.locale') || Craft.locale;

var modal = Craft.createElementSelectorModal('Entry', {
    criteria : {
        locale : currentLocale
    }
});
</code></pre>

CC BY-SA 3.0
2016-03-21T16:46:49.593Z
Can you get the CP's currently selected locale form the js Craft class?
a-am
CC BY-SA 3.0
2016-03-21T16:49:00.893Z
Yeah - its in the answer above; Craft.locale
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2016-03-21T16:49:42.673Z
That only grabs the CP's locale not the currently select locale in the edit entry view.
a-am
CC BY-SA 3.0
2016-03-21T17:06:28.723Z
@aran Sorry, didn't understand that you were looking for the current element index locale. The easiest (only) way I know how to do that, is to look in `localStorage` – just updated my answer.
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2016-03-29T18:19:07.403Z
It appears the only way to get the current selected locale from an entry edit screen is via the local hidden input, which is not the same as BaseElementIndex.locale.
a-am
CC BY-SA 3.0
2016-03-20T09:20:54.657Z
2016-03-21T17:05:36.500Z
2016-03-21T17:05:36.500Z
Mats Mikkel Rummelhoff
<p>When using <code>createElementSelectorModal()</code> in a plugin, how do you make your source list show items from the current locale selected in the CP? It only seems to show the items from default locale no matter what locale you have selected.</p>

<plugin-development><localization><modal><garnish>
When using "createElementSelectorModal()" how do you respect selected locale?
# When using "createElementSelectorModal()" how do you respect selected locale?

(Asked by: username_0 on 2016-03-18)

When using `createElementSelectorModal()` in a plugin, how do you make your source list show items from the current locale selected in the CP? It only seems to show the items from default locale no matter what locale you have selected.

**Tags:** plugin-development, localization, modal, garnish

---

## 1 answers

### Answer by username_1 on 2016-03-20. Score: 2 | Accepted answer

The BaseElementSelectorModal class takes a second parameter settings, which can include a criteria object. This criteria object is used to create an ElementCriteriaModel on the server, which means it can have any property an ElementCriteriaModel can have – including locale:
var currentLocale = Craft.getLocalStorage('BaseElementIndex.locale') || Craft.locale;

var modal = Craft.createElementSelectorModal('Entry', {
    criteria : {
        locale : currentLocale
    }
});

> **Comments:**
> **username_0**: Can you get the CP's currently selected locale form the js Craft class?  
> **username_1**: Yeah - its in the answer above; Craft.locale  
> **username_0**: That only grabs the CP's locale not the currently select locale in the edit entry view.  
> **username_1**: @aran Sorry, didn't understand that you were looking for the current element index locale. The easiest (only) way I know how to do that, is to look in `localStorage` – just updated my answer.  
> **username_0**: It appears the only way to get the current selected locale from an entry edit screen is via the local hidden input, which is not the same as BaseElementIndex.locale.  

---

