How is the language set
blessanm86 opened this issue · 4 comments
Hi I am tying to set the language but i keep getting an error The language must be an object.
My code looks like this
new FlipClock($block.get(0), new Date(endDate), {
face: 'DayCounter',
countdown: true,
language: 'de'
});
Do you have global variable FlipClock.Lang['de']
on your page?
@tangar76 No. It might be the way I use the lib. I require it with the following line
require("flipclock/dist/flipclock");
Also from what I see in the code, none of these language objects are in the final build.
I installed a fork instead flipclock-es6 and that worked
Couple things, I would recommend Babel/and ES6 imports and just import the raw files, and dont mess with the compiled/dist files unless you load the script into the global scope. It should work though, even that way, but I think your bundle size will be smaller. import FlipClock from 'flipclock/src/js/Components/Flipclock'
. require()
might work too, but haven't tested it directly. I just noticed I need to add a module
property to the package.json so it autoloads main.js.
Also for the lang files, I've debated on how to handle this. I really don't like the fact that all the language files are baked into the package, bloating the file size for 30+ languages when people only usually use a few of them. I might create a separate bundle call flipclock.languages.js and compile each language file individually. I also need to test importing specific languages with ES6.
There is an example in the new branch that shows how to use the languages.