The locale setting on V5 scheduler doesn't seem to be working

I’m looking at this option here: https://docs.mobiscroll.com/5-0-2/jquery/eventcalendar#localization-locale

Here’s my code:

  var inst = $('#staffschedule').mobiscroll5().eventcalendar({
    locale: mobiscroll.localeRu,
    display: 'inline',
    calendarHeight: 600,
    themeVariant: 'light',
    responsive: {
        xsmall: {
            view: {
                calendar: {type: 'month'},
                agenda: {type: 'month'}
            }
        },
        small: {
            view: {
                calendar: {type: 'month'}
            }
        }
    },
    onEventSelect: function (event, inst) {
          mobiscroll.toast({
              message: event.event.text
          });
      }
  }).mobiscroll5('getInst');

  inst.setEvents(JSON.parse(data));

But no matter what locale I pass in the scheduler renders in English. Shouldn’t “locale: mobiscroll.localeRu” render the schedular in Russian?

The problem is that the mobiscroll object is for v4, not for v5. You will need to save a reference for the mobiscroll object as well, when loading the v5 version:

  <script src="plugins/mobiscroll5/js/mobiscroll.jquery.min.js"></script>
  <script>
    // Save mobiscroll 5 object before loading v4
    window.mobiscroll5 = mobiscroll;
    $.fn.mobiscroll5 = $.fn.mobiscroll;
  </script>

  <link href="plugins/mobiscroll/css/mobiscroll.jquery.min.css" rel="stylesheet">
  <script src="plugins/mobiscroll/js/mobiscroll.jquery.min.js"></script>

Then use it as: locale: mobiscroll5.localeRu

hmm… That makes sense, but unfortunately I made the changes you suggested and it’s still rendering the calendar in English, no matter what locale I pass in.

I got it. I had to download mobiscroll with the various languages selected. :+1:

Just some feedback on this new locale setting, and perhaps you can help me transition from 4 to 5 in this regard. In V4 you had an option called “lang” and I could pass in a standard IETF-standardized language tag such as ‘en-US’ or ‘en-CA’, and so I built my system around this standard having the users select in their preferences their own locale and saving that standard IETF language tag for each user.

Now you’ve changed your scheduler to no longer accept these tags but instead a proprietary mobiscroll object, which makes my tags virtually useless.

I’m guessing, other than writing a giant switch statement and rendering my javascript from the server, there’s no easy way to do this conversion?

In v5 we moved to locale objects instead of strings, so that the packages can be tree shakeable.
There’s still a way to use the strings, like in v4. We provide a mobiscroll.locale object, which has the locale strings as keys and the locale object as value. Can be used like this:

locale: mobiscroll.locale['ru']

o.k. that’s great. Can I also pass in a 5 character string like ‘en-US’? Or do I have to pass in only ‘en’?

The supported locale strings are the same as for v4, listed here.

If you wish, you can create aliases, before initializing anything, like:

mobiscroll.locale['en-US'] = mobiscroll.locale['en'];
1 Like