Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird i18n language settings and fallbacks in Select2 4.0.3 #5046

Closed
cyrilmesvayn opened this issue Sep 20, 2017 · 10 comments
Closed

Weird i18n language settings and fallbacks in Select2 4.0.3 #5046

cyrilmesvayn opened this issue Sep 20, 2017 · 10 comments

Comments

@cyrilmesvayn
Copy link

Problems

  • HTML lang attribute over-shadow global language configuration
  • no default placeholder in i18n

Expected

Select2 language should be loaded in "French"

Results

Select2 language is "English"

Steps

  1. set <html lang="en">, or whatever else language on a page
  2. insert jQuery 3.1.0
  3. insert select2 4.0.3 css, then js, then i18n file, in that order.
  4. insert script tag with either of the following: $.fn.select2.defaults.set('language', 'fr'); OR using AMD : $.fn.select2.defaults.set('language', $.fn.select2.amd.require("select2/i18n/fr"));
  5. add select2 init : $("#select2").select2({ minimumInputLength: 2, placeholder: 'Test' });

Jsbin

https://jsbin.com/wofisagiqu/edit?html,output

Notes

As per your documentation :
this works as intended, however I find it strange that an explicit javascript declaration is overridden by a top-level lang attribute.

Also, a default placeholder value should be loadable from i18n file, and over-writable with the placeholder option at init time. I don't see in https://select2.org/placeholders something about this, so apologies if it's already possible and I don't know about it.

Thanks for your consideration.

@alexweissman
Copy link
Contributor

TL;DR: A declaration like $.fn.select2.defaults.set('language', 'fr'); should override <html lang="en">, but it doesn't.

@Ketcap
Copy link

Ketcap commented Oct 3, 2017

+1 i got the same error on meteor and it crushes my app so changed version '4.0.3' from '^4.0.3'

@alexweissman
Copy link
Contributor

It looks like #4887 might fix this?

@alexweissman
Copy link
Contributor

@Ketcap wait, does that mean that this has been fixed in a more recent version?

@tuanpht
Copy link

tuanpht commented Feb 19, 2019

Still same problem in version 4.0.5, I have to remove html lang attribute` :(

@tuanpht
Copy link

tuanpht commented Feb 19, 2019

Finnally, I can customize message using this:

    const select2LangJa = $.fn.select2.amd.require('select2/i18n/ja');

    select2LangJa.errorLoading = function () {
        return '';
    }

Related #3799

@stale
Copy link

stale bot commented Apr 21, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Apr 21, 2019
@kevin-brown
Copy link
Member

Is this still a problem in the latest 4.0.6 release?

This would benefit from a failing test case. The fallback to the lang attribute is well documented, but we may want to adjust the order so that it treats any defaults first before falling back to it.

@stale stale bot removed the status: stale label Apr 28, 2019
@ivaynberg ivaynberg added the 4.x label Jun 27, 2019
@stale
Copy link

stale bot commented Aug 26, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Aug 26, 2019
@kevin-brown
Copy link
Member

I believe this is a duplicate of #5602 and was resolved in 4.0.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants