From a0ef06a163cadcac83d6fcf3660a8284dd519ee4 Mon Sep 17 00:00:00 2001
From: Julian Leucker <leuckerj@gmail.com>
Date: Sun, 28 May 2023 14:15:06 +0200
Subject: [PATCH] Load vuetify translations into vue-i18n

---
 CHANGELOG.rst                            |  5 +++++
 aleksis/core/frontend/index.js           |  2 ++
 aleksis/core/frontend/plugins/aleksis.js | 10 ++++++++++
 3 files changed, 17 insertions(+)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index fe7a89aa0..8d5772df9 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -9,6 +9,11 @@ and this project adheres to `Semantic Versioning`_.
 Unreleased
 ----------
 
+Fixed
+~~~~~
+
+* Default translations from vuetify were not loaded.
+
 `3.0`_ - 2022-05-11
 -------------------
 
diff --git a/aleksis/core/frontend/index.js b/aleksis/core/frontend/index.js
index f59aa8578..d7af47fcf 100644
--- a/aleksis/core/frontend/index.js
+++ b/aleksis/core/frontend/index.js
@@ -46,6 +46,7 @@ const vuetify = new Vuetify({
     current: Vue.$cookies.get("django_language")
       ? Vue.$cookies.get("django_language")
       : "en",
+    t: (key, ...params) => i18n.t(key, params),
   },
   ...vuetifyOpts,
 });
@@ -89,5 +90,6 @@ const app = new Vue({
 });
 
 // Late setup for some plugins handed off to out ALeksisVue plugin
+app.$loadVuetifyMessages();
 app.$loadAppMessages();
 app.$setupNavigationGuards();
diff --git a/aleksis/core/frontend/plugins/aleksis.js b/aleksis/core/frontend/plugins/aleksis.js
index c35b9127f..7eb36c27b 100644
--- a/aleksis/core/frontend/plugins/aleksis.js
+++ b/aleksis/core/frontend/plugins/aleksis.js
@@ -5,6 +5,7 @@
 // aleksisAppImporter is a virtual module defined in Vite config
 import { appMessages } from "aleksisAppImporter";
 import aleksisMixin from "../mixins/aleksis.js";
+import * as langs from "@/vuetify/src/locale";
 
 console.debug("Defining AleksisVue plugin");
 const AleksisVue = {};
@@ -115,6 +116,15 @@ AleksisVue.install = function (Vue) {
     }
   };
 
+  /**
+   * Load vuetifys built-in translations
+   */
+  Vue.prototype.$loadVuetifyMessages = function () {
+    for (const [locale, messages] of Object.entries(langs)) {
+      this.$i18n.mergeLocaleMessage(locale, { $vuetify: messages });
+    }
+  };
+
   /**
    * Invalidate state and force reload from server.
    *
-- 
GitLab