Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85629636
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/lib/language.js b/src/lib/language.js
new file mode 100644
index 0000000000..f8904dd077
--- /dev/null
+++ b/src/lib/language.js
@@ -0,0 +1,14 @@
+import { useI18nStore } from 'src/stores/i18n.js'
+
+export const piniaLanguagePlugin = ({ store, options }) => {
+ if (store.$id === 'sync_config') {
+ store.$onAction(({ name, args }) => {
+ if (name === 'setPreference') {
+ const { path, value } = args[0]
+ if (path === 'simple.interfaceLanguage') {
+ useI18nStore().setLanguage(value)
+ }
+ }
+ })
+ }
+}
diff --git a/src/stores/i18n.js b/src/stores/i18n.js
index 4e7c7c5d3d..a18b1d4d25 100644
--- a/src/stores/i18n.js
+++ b/src/stores/i18n.js
@@ -1,14 +1,34 @@
+import Cookies from 'js-cookie'
import { defineStore } from 'pinia'
+import { useEmojiStore } from 'src/stores/emoji.js'
+import { useSyncConfigStore } from 'src/stores/sync_config.js'
+
+import messages from 'src/i18n/messages'
+import localeService from 'src/services/locale/locale.service.js'
+
+const BACKEND_LANGUAGE_COOKIE_NAME = 'userLanguage'
+
export const useI18nStore = defineStore('i18n', {
state: () => ({
i18n: null,
}),
actions: {
setI18n(newI18n) {
this.$patch({
i18n: newI18n.global,
})
},
+ setLanguage(originalValue) {
+ const value =
+ originalValue || useSyncConfigStore().mergedConfig.interfaceLanguage
+
+ messages.setLanguage(this.i18n, value)
+ useEmojiStore().loadUnicodeEmojiData(value)
+ Cookies.set(
+ BACKEND_LANGUAGE_COOKIE_NAME,
+ localeService.internalToBackendLocaleMulti(value),
+ )
+ },
},
})
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Aug 9, 2:02 AM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1724124
Default Alt Text
(1 KB)
Attached To
Mode
rPUFE pleroma-fe-upstream
Attached
Detach File
Event Timeline
Log In to Comment