bootstrap-select icon indicating copy to clipboard operation
bootstrap-select copied to clipboard

how to use i18n

Open valix85 opened this issue 12 years ago • 13 comments

Hello, is it possible to have a guide for use other languafe in i18n? i need to load Italian language for this component, whan can i do it?

thank you

valix85 avatar Nov 26 '14 11:11 valix85

@valix85 you just need to load the javascript file with the language you want after the main selectpicker.js file but before your first call to .selectpicker();

As long as the file is loaded before your first call (and after the main file that loads in selectpicker) it should be good to go.

truckingsim avatar Dec 01 '14 02:12 truckingsim

ok, it's work! thank you very much

valix85 avatar Dec 02 '14 07:12 valix85

LIKE THIS

ochafloquet avatar Feb 10 '17 18:02 ochafloquet

Only put the language.js and it works

ochafloquet avatar Feb 10 '17 18:02 ochafloquet

I've been trying to figure out how to do this for days and can't get it to work. I emailed Silvio to no avail. Could someone please post complete example of how to use the right locale file when using this module?

dfarm3r avatar Jun 28 '17 20:06 dfarm3r

Simply load the language file after bootstrap-select.

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/i18n/defaults-de_DE.min.js"></script>

caseyjhol avatar Jun 29 '17 00:06 caseyjhol

This doesn't seem to work. Still seeing English text within the dropdown for "select all" and "deselect all".

On Wed, Jun 28, 2017 at 8:16 PM, Casey Holzer [email protected] wrote:

Simply load the language file after bootstrap-select.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/silviomoreto/bootstrap-select/issues/813#issuecomment-311826989, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEpgqY_zTBldCP8rQ0G6-Ap3rgDhYpNks5sIuzXgaJpZM4DA5nR .

dfarm3r avatar Jun 29 '17 14:06 dfarm3r

So, it does work. Just turns out these are not translated for German. Thanks

On Thu, Jun 29, 2017 at 10:27 AM, Doug Farmer [email protected] wrote:

This doesn't seem to work. Still seeing English text within the dropdown for "select all" and "deselect all".

On Wed, Jun 28, 2017 at 8:16 PM, Casey Holzer [email protected] wrote:

Simply load the language file after bootstrap-select.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/silviomoreto/bootstrap-select/issues/813#issuecomment-311826989, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEpgqY_zTBldCP8rQ0G6-Ap3rgDhYpNks5sIuzXgaJpZM4DA5nR .

dfarm3r avatar Jun 29 '17 15:06 dfarm3r

Hrmm...they should be translated for German: https://github.com/silviomoreto/bootstrap-select/blob/master/dist/js/i18n/defaults-de_DE.js#L37-L38

caseyjhol avatar Jul 07 '17 20:07 caseyjhol

It would be better to select language in options :-(

aolszak avatar Feb 29 '20 21:02 aolszak

At some point we'll add the option to select the language in the options, but you'll still always have to load the language files separately.

caseyjhol avatar Mar 04 '20 18:03 caseyjhol

Let me know when the option feature is sorted, Ta!

NeilAllen avatar Apr 21 '20 12:04 NeilAllen

For those using webpack there is solution using require function:

<html lang="cs">
const langMap = {
    cs: "cs_CZ",
    en: "en_US",
};

if (document.documentElement.lang in langMap) {
    require("bootstrap-select/js/i18n/defaults-" + langMap[document.documentElement.lang]);
} else {
    console.error("Unknown language " + document.documentElement.lang);
}

adaamz avatar Jun 16 '20 13:06 adaamz