Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How is the language set #365

Open
blessanm86 opened this issue Nov 12, 2018 · 4 comments
Open

How is the language set #365

blessanm86 opened this issue Nov 12, 2018 · 4 comments

Comments

@blessanm86
Copy link

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'
});
@tangar76
Copy link

Do you have global variable FlipClock.Lang['de'] on your page?

@blessanm86
Copy link
Author

blessanm86 commented Nov 14, 2018

@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.

@blessanm86
Copy link
Author

blessanm86 commented Nov 14, 2018

I installed a fork instead flipclock-es6 and that worked

@objectivehtml
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants