Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

Select2 Internationalization


Hello, how are you? I wanted to know how to translate the text 'No results found' from Select2 using Metronic 8.

https://preview.keenthemes.com/html/metronic/docs/forms/select2

Is there an example https://select2.org/i18n

$(".js-example-language").select2({
language: "es"
});


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (4)


I want to be able to add another language "es and pt-BR"



Hi,

Please add the required language's source in the select2 plugin build:


select2: {
styles: [
"{$config.path.node_modules}/select2/dist/css/select2.css",
],
scripts: [
"{$config.path.node_modules}/select2/dist/js/select2.full.js",
"{$config.path.node_modules}/select2/dist/js/i18n/es.js",
"{$config.path.common_src}/js/vendors/plugins/select2.init.js",
],
},


in tools/gulp.config.js and recompile assets with gulp as explained in the docs.

Regards.



So if I just do this, it will work?

select2: {
styles: [
"{$config.path.node_modules}/select2/dist/css/select2.css",
],
scripts: [
"{$config.path.node_modules}/select2/dist/js/select2.full.js",
"{$config.path.node_modules}/select2/dist/js/i18n/es.js",
"{$config.path.node_modules}/select2/dist/js/i18n/pt-BR.js",
"{$config.path.common_src}/js/vendors/plugins/select2.init.js",
],
},

And to use it, would I have to add this code too?

$(".form-select").select2({
language: "pt-BR"
});



Hi,

Yes, you just need to modify the gulp config, recompile the assets, and use the below select2 init code with the required lang.

Regards.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(