首页 > 解决方案 > 如何在 Vue.js 中获得 fullCalendar 的完整翻译

问题描述

我的 Vue 应用程序中有 Fullcalendar 并将语言设置为“da”,但它并不能翻译所有内容。

角落里的“今天”按钮没有翻译,但其他所有内容都翻译了。

我试图导入语言环境文件。all 和“da”。

import daLocale from '@fullcalendar/core/locales/da'
import allLocales from '@fullcalendar/core/locales-all'

我也尝试将“allLocales”直接放在<fullCalender>标签上

    <FullCalendar
       class="demo-app-calendar"
       ref="fullCalendar"
       defaultView="dayGridMonth"
       :plugins="calendarPlugins"
       :events="calendarEvents"
       locale="da"
       :locales="allLocales"
     />

我已经尝试将 CDN 设置为<head>

<script src='fullcalendar/core/locales-all.js'></script>
<script src='fullcalendar/core/locales/da.js'></script>

我已经阅读了文档中的所有内容,并且在有关语言环境的文档中,它没有显示如何在 Vue.js DOCS中进行操作

我应该做任何其他设置来获得完整的翻译吗?

标签: vue.jsfullcalendarlocalefullcalendar-4

解决方案


这是我的答案。

import FullCalendar from "@fullcalendar/vue";
import esLocale from "@fullcalendar/core/locales/es";

... ...

data() {
  return {
    calendarOptions: {
      plugins: [dayGridPlugin, interactionPlugin],
      initialView: "dayGridMonth",
      locale: esLocale,
      headerToolbar: {
        left: "title",
        right: "today dayGridWeek dayGridMonth",
      },
    },
  };
}

... ...

<FullCalendar
  ref="fullcalendar"
  :options="calendarOptions"
/>


推荐阅读