|
|
|
@ -1,4 +1,3 @@
|
|
|
|
import type { StrapiLocale } from '@nuxtjs/strapi';
|
|
|
|
|
|
|
|
import type { Language as ElementLanguage } from 'element-plus/es/locale';
|
|
|
|
import type { Language as ElementLanguage } from 'element-plus/es/locale';
|
|
|
|
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
|
|
|
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
|
|
|
import en from 'element-plus/es/locale/lang/en';
|
|
|
|
import en from 'element-plus/es/locale/lang/en';
|
|
|
|
@ -8,8 +7,6 @@ import en from 'element-plus/es/locale/lang/en';
|
|
|
|
* 用于统一 Strapi / Directus / Element Plus 的多语言配置
|
|
|
|
* 用于统一 Strapi / Directus / Element Plus 的多语言配置
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export interface LocaleMapping {
|
|
|
|
export interface LocaleMapping {
|
|
|
|
/** 用于StrapiLocale **/
|
|
|
|
|
|
|
|
strapi: StrapiLocale;
|
|
|
|
|
|
|
|
/** 用于Directus translations.languages_code **/
|
|
|
|
/** 用于Directus translations.languages_code **/
|
|
|
|
directus: string;
|
|
|
|
directus: string;
|
|
|
|
/** Element Plus语言对象 **/
|
|
|
|
/** Element Plus语言对象 **/
|
|
|
|
@ -24,12 +21,10 @@ export interface LocaleMapping {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export const localeMap = {
|
|
|
|
export const localeMap = {
|
|
|
|
zh: {
|
|
|
|
zh: {
|
|
|
|
strapi: 'zh-CN',
|
|
|
|
|
|
|
|
directus: 'zh-CN',
|
|
|
|
directus: 'zh-CN',
|
|
|
|
element: zhCn,
|
|
|
|
element: zhCn,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
en: {
|
|
|
|
en: {
|
|
|
|
strapi: 'en',
|
|
|
|
|
|
|
|
directus: 'en-US',
|
|
|
|
directus: 'en-US',
|
|
|
|
element: en,
|
|
|
|
element: en,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -74,8 +69,6 @@ export const useLocalizations = () => {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
/** 当前Nuxt I18n语言(只读) **/
|
|
|
|
/** 当前Nuxt I18n语言(只读) **/
|
|
|
|
locale: readonly(locale),
|
|
|
|
locale: readonly(locale),
|
|
|
|
/** 获取Strapi的本地化代码 **/
|
|
|
|
|
|
|
|
getStrapiLocale: (l?: AppLocale) => getMapping(l).strapi,
|
|
|
|
|
|
|
|
/** 获取Directus的本地化代码 **/
|
|
|
|
/** 获取Directus的本地化代码 **/
|
|
|
|
getDirectusLocale: (l?: AppLocale) => getMapping(l).directus,
|
|
|
|
getDirectusLocale: (l?: AppLocale) => getMapping(l).directus,
|
|
|
|
/** 获取Element Plus语言对象 **/
|
|
|
|
/** 获取Element Plus语言对象 **/
|
|
|
|
|