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

locale documentation #101

Closed
shrpne opened this issue Mar 23, 2018 · 27 comments
Closed

locale documentation #101

shrpne opened this issue Mar 23, 2018 · 27 comments
Assignees
Labels

Comments

@shrpne
Copy link

shrpne commented Mar 23, 2018

Looks like locale options is not documented. I don't see it in the props list

@rodolfosaraiva
Copy link

Same issue, how can i change locale?

@nathanreyes
Copy link
Owner

nathanreyes commented Mar 26, 2018

Locale can be set up one of two ways.

  1. Automatically: Let the plugin detect the user's locale (uses Intl.DateTimeFormat().resolvedOptions().locale)
  2. Manually pass in a locale string as an option:
import Vue from 'vue';
import VCalendar from 'v-calendar';

Vue.use(VCalendar, {
  locale: 'es' // Spanish
});

Note: If you use the manual approach, that locale will get forced for all users internationally.

As of now, the reason it is not documented is because I see little benefit to forcing all users to use one specific locale.

The only downside to this approach is if you need a locale that is not supported out of the box. See the list for reference. If that is the case, I would need to add support for passing in a custom locale object.

@niksib
Copy link

niksib commented Apr 3, 2018

@nathanreyes How can I change locale if I use the calendar from CDN?

@nathanreyes
Copy link
Owner

Currently, there is no way to force a locale via CDN. However, it still does try and detect the locale automatically. Is there a specific locale you had in mind that needed to be supported?

@niksib
Copy link

niksib commented Apr 3, 2018

@nathanreyes I need ukrainian, if you can't add this language, how can i customize calendar?.

@EricMcRay
Copy link
Contributor

@niksib you can do a little hack like below. You can pass any options and reinstall any plugin which not available on global scope.

Vue._installedPlugins.find(function(plugin){
  if(plugin.hasOwnProperty('Calendar')){
     plugin.install(Vue, { locale: 'uk'})
  }
});

@niksib
Copy link

niksib commented Apr 4, 2018

@EricMcRay Thanks, but the calendar doesn't support the Ukrainian language.

@niksib
Copy link

niksib commented Apr 4, 2018

@EricMcRay when I use your little hack and set weekends(Saturday, Sunday)

{
   highlight: {
      backgroundColor: '#e9ecef',
  },
  contentStyle: {
     color: '#333',
  },
  dates: [
      {
         weekdays: [6, 7],
       },
  ],
}

I have this:
image

@nathanreyes
Copy link
Owner

@niksib What version of the plugin are you currently using?

@niksib
Copy link

niksib commented Apr 4, 2018

@nathanreyes Sorry it's my fail, I had to put this: weekdays: [1, 7]
1 - Saturday, 7 - Sunday
But I'm still waiting Ukrainian :)

@nathanreyes
Copy link
Owner

@niksib Yes, I was about to post that :)

@nathanreyes
Copy link
Owner

To resolve this issue, a bug will get fixed that will support all locales supported by Intl.DateTimeFormat (not just those that aren't cross-checked with the plugin). @niksib This should fix Ukrainian locale detection.

Also, the docs site will more elaborately explain how locales are resolved.

@nathanreyes
Copy link
Owner

Resolved by 19b8d6f.

@achwilko
Copy link

achwilko commented May 4, 2018

I really appreciate you work on v-calendar but I have a silly question - how can I update locales during application lifetime?

I'm setting locales during installation, like below:

import Vue from 'vue';
import VCalendar from 'v-calendar';

Vue.use(VCalendar, {
  locale: 'pl-PL'
});

..and wondering how can I change above locale in component's method etc. Is there any workaround?

@lgomes2m
Copy link

I have the same problem as @achwilko
I need to change language on the run.
Is there a solution?

Thanks!

@hisenbergguj
Copy link

@lgomes2m having the same trouble, did you find any solution for that?

@lgomes2m
Copy link

lgomes2m commented Sep 20, 2018

@hisenbergguj
Yes, I did a workaround.

At template I put a key at v-date-picker:

`<v-date-picker

    mode="single"

    v-model="selectedValue"

    :theme-styles='themeStyles'

    :is-inline="true"

    :available-dates="availableDates"

    :min-date="new Date()"

    :max-date="$moment().add(1, 'M').toDate()"

    v-on:dayclick="daySelected"

    @update:page="monthChange"

    :key="currentLanguage" 
  >
  </v-date-picker>`

And currentLanguage is a computed var:

`computed: {

currentLanguage() {

  setupCalendar({

    locale: this.$store.getters['current_language'] == "br" ? "pt" : "en"

  })

  return this.$store.getters['current_language']

}

}`

When you call setupCalendar() it didn't re render vcalendar but it actually change its locale, I am using currentLanguage as a key because when it changes it forces de component to render again and now it will use the correct language.

@Chemahin gave another solution here but I didn't test it yet.

I hope it helps you.

@hisenbergguj
Copy link

@lgomes2m I have tried your solution but it gives me "setupCalendar" is not defined".
I have already import it like this : import VCalendar, {setupCalendar} from 'v-calendar';

do you have any idea, what am I doing wrong here?

@alehandro-dev
Copy link

alehandro-dev commented Sep 21, 2018 via email

@lgomes2m
Copy link

lgomes2m commented Sep 21, 2018

@hisenbergguj

Sorry.... I don't know why...
I am importing like this:
import { setupCalendar, Calendar } from 'v-calendar'

And in main.js:

import VCalendar from 'v-calendar'
Vue.use(VCalendar)

@alehandro-dev
Copy link

alehandro-dev commented Sep 21, 2018 via email

@alehandro-dev
Copy link

alehandro-dev commented Sep 21, 2018 via email

@nr007
Copy link

nr007 commented Oct 30, 2018

Hey @nathanreyes, thank you very much for your work on this amazing calendar! I have one request... Could you add support for Slovenian locale (sl-SI)? It has the same date format as Croatian. Thank you!

@nxic
Copy link

nxic commented Apr 6, 2020

Locale can be set up one of two ways.

  1. Automatically: Let the plugin detect the user's locale (uses Intl.DateTimeFormat().resolvedOptions().locale)
  2. Manually pass in a locale string as an option:
import Vue from 'vue';
import VCalendar from 'v-calendar';

Vue.use(VCalendar, {
  locale: 'es' // Spanish
});

Note: If you use the manual approach, that locale will get forced for all users internationally.

As of now, the reason it is not documented is because I see little benefit to forcing all users to use one specific locale.

The only downside to this approach is if you need a locale that is not supported out of the box. See the list for reference. If that is the case, I would need to add support for passing in a custom locale object.

I want to set custom locale all my date-pickers across my project but it isn't working. It's kinda only available if I set locale attribute on all my date-pickers one by one. How could I set locale default in Vue.use or something.

    Vue.use(VCalendar, {
      componentPrefix: 'v',
      locale: 'mn-MN',
      locales: {
        'mn-MN': {
          firstDayOfWeek: 2,
          masks: {
            L: "YYYY-MM-DD",
          }
        }
      }
    });

but it won't make any changes

<v-date-picker v-model="filters.from" :input-props="{ placeholder: $t('startDate') }" locale="mn-MN" class="form-control date"/>

if I set my locale on every use I could use my declared locale without problem show as like above.

@titosobabas
Copy link

titosobabas commented Jul 4, 2022

I'm from Mexico, so I needed to display the weekdays in spanish, so I used this code:

<v-calendar
    locale="es"
></v-calendar>

But as this translate to spanish weekday names in lowercase I had to add a css rule (this is up to you) to capitalize the weekday to something like "Lunes" and not "lunes" like this:


<style>
.vc-weekday {
    text-transform: capitalize;
}
</style>

Cheers

@AlmasF
Copy link

AlmasF commented Jan 4, 2023

Hello, can you please add kk-KZ locale nathanreyes

@redhemd
Copy link

redhemd commented May 31, 2024

i second @AlmasF. can you add kk-KZ please

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

No branches or pull requests