简体   繁体   English

如何在select2中更改语言

[英]How to change language in select2

i'm using select2 in v4.0.3 我在v4.0.3中使用select2

I want to change the default language from English to Spanish. 我想将默认语言从英语更改为西班牙语。 Check the documentation in the internationalization section, but, as indicated, it has not worked for me. 检查国际化部分中的文档,但是,如所示,它对我没有用。

I am attentive to your comments anex code 我关注您的评论anex代码

 $("#multisearch").select2({ language: "es", closeOnSelect: false, placeholder: "Comienza tu búsqueda", data: [ { id: 0, text: 'Linea 1', children: [{ id: 1, text: 'San Pablo' }, { id: 2, text: 'Pajaritos' }, { id: 3, text: 'Las Rejas' }, { id: 4, text: 'Ecuador' }] }, { id: 5, text: 'Linea 2', children: [{ id: 6, text: 'La Cisterna' }, { id: 7, text: 'El Parrón' }, { id: 8, text: 'Lo Ovalle' }, { id: 9, text: 'Ciudad del niño' }, { id: 10, text: 'Pajaritos' } ] }, { id: 1, text: 'prueba' }, ]}); 
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script> <select multiple id="multisearch" style="width:500px"> </select> 

I will be attentive, thank you very much 我会细心的,非常感谢

 $("#multisearch").select2({ language: "es", closeOnSelect: false, placeholder: "Comienza tu búsqueda", data: [ { id: 0, text: 'Linea 1', children: [{ id: 1, text: 'San Pablo' }, { id: 2, text: 'Pajaritos' }, { id: 3, text: 'Las Rejas' }, { id: 4, text: 'Ecuador' }] }, { id: 5, text: 'Linea 2', children: [{ id: 6, text: 'La Cisterna' }, { id: 7, text: 'El Parrón' }, { id: 8, text: 'Lo Ovalle' }, { id: 9, text: 'Ciudad del niño' }, { id: 10, text: 'Pajaritos' } ] }, { id: 1, text: 'prueba' }, ]}); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script> <select multiple id="multisearch" style="width:500px"> </select> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM