admin管理员组

文章数量:1278916

i'm trying to change the language of the labels on a FlipClock.js clock programatically, when the user selects a language from a dropdown.

i see how to set the language when instantiating the clock (.html) and i see the docs here but I'm not sure how to dynamically change the language.

something like:

var clock = $('#flipclock').FlipClock(6000, {
    countdown: true,
    clockFace: 'DailyCounter'
});

clock.loadLanguage("es"); // change language? doesn't work

but that doesn't work. i also tried

clock.language = "es"; 

and that didn't work either. any ideas?

i'm trying to change the language of the labels on a FlipClock.js clock programatically, when the user selects a language from a dropdown.

i see how to set the language when instantiating the clock (https://github./objectivehtml/FlipClock/blob/master/examples/localization.html) and i see the docs here http://flipclockjs./api but I'm not sure how to dynamically change the language.

something like:

var clock = $('#flipclock').FlipClock(6000, {
    countdown: true,
    clockFace: 'DailyCounter'
});

clock.loadLanguage("es"); // change language? doesn't work

but that doesn't work. i also tried

clock.language = "es"; 

and that didn't work either. any ideas?

Share Improve this question asked Aug 12, 2014 at 20:53 split19split19 6378 silver badges19 bronze badges 1
  • I can't seem to see anything on their API docs, so my suggestion may be a little convoluted. When the user chooses a new language, save the current time of the clock, destroy the current clock, and then reinstantiate it with the new language and old time – Brennan Commented Aug 12, 2014 at 20:57
Add a ment  | 

2 Answers 2

Reset to default 9
var clock = $('#flipclock').FlipClock(6000, {
    countdown: true,
    clockFace: 'DailyCounter',
    language:'es-es',
});
clock.setOptions('language', 'spanish');

本文标签: javascriptdynamically change language on flipclockjsStack Overflow