mengxiong10 / vue2-datepicker

A datepicker / datetimepicker component for Vue2
https://mengxiong10.github.io/vue2-datepicker/index.html
MIT License
1.51k stars 405 forks source link

Change the name of the header title #710

Closed cylace closed 2 years ago

cylace commented 2 years ago

Hi, how can i change the 'mx-calendar-title-label' ?? I would change the title jun to juni for exemple (complète word not the three first letters). And wat is the method for translations for this ?? i've a website with 3 translations. For moment, i've that: image

i would that: image

THank you so much for your help :)

mengxiong10 commented 2 years ago
<date-picker  :lang="lang"/>
data() {
  return {
        lang: {
          monthFormat: 'MMMM',
        },
  }
}

https://github.com/mengxiong10/vue2-datepicker/blob/master/locale.md

cylace commented 2 years ago

@mengxiong10 thank you so much. One question, for multi languages it doesn't work on my website. it's always on the same language. i add this : image

and add this on datepicker :

image

cylace commented 2 years ago

i tried this too: image

mengxiong10 commented 2 years ago

You can change the global object.

<date-picker lang="en" />
import zh from 'vue2-datepicker/locale/zh-cn'
import en from 'vue2-datepicker/locale/en'

zh.monthFormat = 'MMMM'
en.monthFormat = 'MMMM'
cylace commented 2 years ago

I tried this but it's not correct it's strange. i've three languages

mengxiong10 commented 2 years ago

Can you show your code ?

cylace commented 2 years ago

image It's my code, i've tried with method above but not correct. i search for moment :)

cylace commented 2 years ago

i tried with this method too : image

cylace commented 2 years ago

i've that image

i've good the full name but the translation is always on the same language for that.

i use :lang=lang and i've good a default lang but i add the method changeLang ()

mengxiong10 commented 2 years ago
<date-picker :lang="lang" />
import DatePicker from "vue2-datepicker";
import "vue2-datepicker/index.css";
import en from "vue2-datepicker/locale/en";
import fr from 'vue2-datepicker/locale/fr';

en.monthFormat = "MMMM";
fr.monthFormat = 'MMMM';
DatePicker.locale("en", en);
DatePicker.locale("fr", fr);

export default {
  data() {
    return { lang: 'en'}
  },
methods: {
    changeLang () {
       this.lang = this.lang === 'en ' ? 'fr' : 'en'
    }
 }
}
cylace commented 2 years ago

Hi, i don't know why but i think that changeLang don't work. i try this and it's not working. [image: image.png] and it's my method for that. maybe add changeLang on <Date-picker :lang=lang ... /> .????

Op vr 1 jul. 2022 om 04:35 schreef 也无风雨 @.***>:

import DatePicker from "vue2-datepicker";import "vue2-datepicker/index.css";import en from "vue2-datepicker/locale/en";import fr from 'vue2-datepicker/locale/fr'; en.monthFormat = "MMMM";fr.monthFormat = 'MMMM';DatePicker.locale("en", en);DatePicker.locale("fr", fr); export default { data() { return { lang: 'en'} },methods: { changeLang () { this.lang = this.lang === 'en ' ? 'fr' : 'en' } }}

— Reply to this email directly, view it on GitHub https://github.com/mengxiong10/vue2-datepicker/issues/710#issuecomment-1171862686, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANYHVJNP4QQB37UDM2IBH43VRZKQZANCNFSM52GC3CUA . You are receiving this because you authored the thread.Message ID: @.***>

mengxiong10 commented 2 years ago

Add a key for the component

<date-picker :lang="lang" :key="lang" />
cylace commented 2 years ago

i think that the problem is with an other module (as vui18n) because all is worked except that

cylace commented 2 years ago

Hi, unfortunately it's not working for me i don't know why. Maybe because other modules like vuei18n for translations ?

mengxiong10 commented 2 years ago

@cylace Maybe other global plugin change the methods.

cylace commented 2 years ago

ok thank you for your help. You're great ! And Very reactif. Thanks.