gaoluyang
2026-06-24 c0cb161bb52ce0fbdce5c66ec391d107c75e2452
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<script setup lang="ts">
import type { SupportedLanguagesType } from '..\..\..\..\locales\src';
 
import { SUPPORT_LANGUAGES } from '..\..\..\..\constants\src';
import { Languages } from '..\..\..\..\icons\src';
import { loadLocaleMessages } from '..\..\..\..\locales\src';
import { preferences, updatePreferences } from '..\..\..\..\preferences\src';
 
import { VbenDropdownRadioMenu, VbenIconButton } from '..\..\..\..\@core\ui-kit\shadcn-ui\src';
 
defineOptions({
  name: 'LanguageToggle',
});
 
async function handleUpdate(value: string | undefined) {
  if (!value) return;
  const locale = value as SupportedLanguagesType;
  updatePreferences({
    app: {
      locale,
    },
  });
  await loadLocaleMessages(locale);
}
</script>
 
<template>
  <div>
    <VbenDropdownRadioMenu
      :menus="SUPPORT_LANGUAGES"
      :model-value="preferences.app.locale"
      @update:model-value="handleUpdate"
    >
      <VbenIconButton class="hover:animate-[shrink_0.3s_ease-in-out]">
        <Languages class="size-4 text-foreground" />
      </VbenIconButton>
    </VbenDropdownRadioMenu>
  </div>
</template>