i18n problem.

2,483 views
Skip to first unread message

gonza...@gmail.com

unread,
Mar 17, 2015, 8:00:34 AM3/17/15
to sel...@googlegroups.com
Hi, I'm using Select2 and I can't set the language successfully.

Im trying the next code (simplified):

$('#customers').select2({language: '/company/web/js/select2/i18n/es.js' });

the directory exists and is reachable from my browser. I've read the documentation several times:

https://select2.github.io/options.html#language

Cite:
When a string is passed in as the language, Select2 will try to resolve it into a language file. This allows you to specify your own language files, which must be defined as an AMD module.
---

I pass a valid language file and doesn't work, I'm doing something bad or there are a bug?

Any help will be appreciated!

Note: I've tried too to put: { language: 'es' } and a lot of variables with no effect

Kevin Brown

unread,
Mar 31, 2015, 6:22:10 PM3/31/15
to sel...@googlegroups.com
Sorry for not responding earlier.

You should be able to use `language: 'es'` to specify the language, but you have to make sure to include the language file in the page before you initialize Select2 (but after you include Select2). Select2 cannot automatically load files, unless you are in a strict AMD environment using an AMD loader (you aren't), so you still have to include them on the page.

For the examples page in the documentation we do this right at the top.

Kevin Brown


--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.
To post to this group, send email to sel...@googlegroups.com.
Visit this group at http://groups.google.com/group/select2.
For more options, visit https://groups.google.com/d/optout.

i.am....@gmail.com

unread,
Apr 7, 2016, 12:12:08 PM4/7/16
to select2, ke...@kevinbrown.in
Kevin can you point me about using language option dynamically (via RequireJS for example)?

Reading different issues i didn't realise how and when it needed to set correct setting(s)... =\

Message has been deleted

Ali Shan Backlinks

unread,
Dec 18, 2025, 10:16:55 AM (20 hours ago) Dec 18
to select2

This is a common point of confusion with Select2 language configuration. In most cases, the issue isn’t a bug but how the language file is loaded—Select2 expects the language file to be properly included or bundled as an AMD module, not just referenced by a path string. Usually, loading the es.js file explicitly before initializing Select2 and then using { language: 'es' } resolves the problem. Discussions like this are helpful for others running into similar setup issues and are often shared in developer communities such as https://nyweeklyinfo.co.uk/

Reply all
Reply to author
Forward
0 new messages