javascript - FullCalendar today-button: date instead of text // issue with the lang -
i want show current date instead of fixed text in today-button. >> irismediainfo3.lili.de development-website working on. not find option in docs, searched in moment.js-docs , found:
moment().format();
and used in fullcalendar this:
buttontext: { next: '>', nextyear: '>>', prev: '<', prevyear: '<<', today: moment().format("mmmm yyyy") },
the result good, in english. fullcalendar should multilingual, tried combined with
moment.locale(string);
first try:
buttontext: { next: '>', nextyear: '>>', prev: '<', prevyear: '<<', today: moment().locale('de').format("mmmm yyyy") },
but there no changes. thought moment.js maybe access lang-files of fullcalendar. , here comes first question:
moment.js included in fullcalendar. have put lang-files in fullcalendar directory make accessible moment.js?
i found more complex syntax , next try did not crash fullcalendar was:
buttontext: { next: '>', nextyear: '>>', prev: '<', prevyear: '<<', today: moment().locale('de', {months : "januar_februar_märz_april_mai_juni_juli_august_september_oktober_november_dezember".split("_")}).format("mmmm yyyy") },
it did not crash fullcalendar, did not have influence.
actually 'de' in code , long string months names created compiler of cms use. called spip. url @ beginning contains language-variable. if change variable "en", "fr" or "de" (others work well, website made languages) can see fullcalendar changing language. today-button stays in english. language-variable url given fullcalendar code automatically. long rest of fullcalendar changing language variable url passed correctly.
i tried take full moment.js code languages momentjs.com homepage , paste in moment.js file in fullcalendar lib directory. language did not change.
is possible define language moment.js supposed use inline?
thanks time , help. nils t.
well, found out how it.
step 1: languages. go locale directory of moment.js on github , download languages need. took de.js, en.js & fr.js.
step 2: upload them server. made new folder in fullcalendar directory on server , called "momentjs_locale" , uploaded files there.
step 3: link languages files. safe linked them in same place link fullcalendar files right behind link moment.js me looks like:
<link href='../fullcalendar.css' rel='stylesheet' /> <link href='../fullcalendar.print.css' rel='stylesheet' media='print' /> <script src='../lib/moment.min.js'></script> <script src="momentjs_locale/de.js"></script> <script src="momentjs_locale/en.js"></script> <script src="momentjs_locale/fr.js"></script> <script src='../lib/jquery.min.js'></script> <script src='../fullcalendar.min.js'></script>
step 4: use it. can use languages described in documentation of moment.js.
<script> $(document).ready(function() { //here setting global language moment.js german (which "en" default.) moment.locale("de"); $('#calendar').fullcalendar({ buttontext: { //here make button show french date instead of text. today: moment().locale("fr").format("mmmm yyyy") }, //more options... }); }); </script>
so if got similar question, hope it. ciao :)
How to convert text to speech using PHP
ReplyDeleteHow to create a multiple choice quiz in PHP and MySQL
Python Convert XML to CSV
Python 3 Tkinter Menu Bar
Python Tkinter Text Widget