longbill / jquery-date-range-picker

A jQuery plugin that allows user to select a date range
MIT License
1.12k stars 579 forks source link

Separate language files #336

Open holtkamp opened 7 years ago

holtkamp commented 7 years ago

Initial approach to separate non-default language files

holtkamp commented 7 years ago

A problem is that the language files as loaded by $.ajax should be located relative to the HTML page (and not relative to the .js file) that uses the functionality, so using relative URLs will be a no-go... 😞

http://stackoverflow.com/questions/36369082/relative-paths-with-fetch-in-javascript

mazipan commented 7 years ago

maybe we can setup browsersync (https://browsersync.io/) for gulp in development phase. so there is no problem with ajax.

holtkamp commented 7 years ago

@mazipan I don't see how this circumvents the problem?

Suppose I have a webpage, which references to the JavaScript files on CDNJS:

Then the English translation file will be loaded relative to the .html page, so from:

Instead of: https://cdnjs.cloudflare.com/ajax/libs/jquery-date-range-picker/0.14.4/locales/en.json

We might be able to circumvent this by introducing a configuration option basePath that a user has to point to https://cdnjs.cloudflare.com/ajax/libs/jquery-date-range-picker/0.14.4/, but I think that is a big disadvantage / not worth it...