Просмотр исходного кода

Merge pull request #6656 from weseek/fix/105556-fix-i18n-admin

fix: show language lists in admin app setting
Yuki Takei 3 лет назад
Родитель
Сommit
f66eac3c12

+ 3 - 0
packages/app/public/static/locales/en_US/admin.json

@@ -1,4 +1,7 @@
 {
 {
+  "meta": {
+    "display_name": "English"
+  },
   "wiki_management_home_page": "Wiki Management Home Page",
   "wiki_management_home_page": "Wiki Management Home Page",
   "app_settings": "App Settings",
   "app_settings": "App Settings",
   "security_settings": {
   "security_settings": {

+ 3 - 0
packages/app/public/static/locales/ja_JP/admin.json

@@ -1,4 +1,7 @@
 {
 {
+  "meta": {
+    "display_name": "日本語"
+  },
   "Update": "更新",
   "Update": "更新",
   "Delete": "削除",
   "Delete": "削除",
   "User": "ユーザー",
   "User": "ユーザー",

+ 3 - 0
packages/app/public/static/locales/zh_CN/admin.json

@@ -1,4 +1,7 @@
 {
 {
+  "meta": {
+    "display_name": "简体中文"
+  },
   "Update": "更新",
   "Update": "更新",
   "Delete": "删除",
   "Delete": "删除",
   "User": "用户",
   "User": "用户",

+ 2 - 2
packages/app/src/components/Admin/App/AppSetting.jsx

@@ -79,8 +79,8 @@ const AppSetting = (props) => {
         <div className="col-md-6 py-2">
         <div className="col-md-6 py-2">
           {
           {
             i18nConfig.locales.map((locale) => {
             i18nConfig.locales.map((locale) => {
-              const fixedT = i18n.getFixedT(locale);
-              i18n.loadLanguages(i18nConfig.locales);
+              if (i18n == null) { return }
+              const fixedT = i18n.getFixedT(locale, 'admin');
 
 
               return (
               return (
                 <div key={locale} className="custom-control custom-radio custom-control-inline">
                 <div key={locale} className="custom-control custom-radio custom-control-inline">

+ 2 - 1
packages/app/src/pages/admin/[[...path]].page.tsx

@@ -307,7 +307,8 @@ async function injectServerConfigurations(context: GetServerSidePropsContext, pr
  * @param namespacesRequired
  * @param namespacesRequired
  */
  */
 async function injectNextI18NextConfigurations(context: GetServerSidePropsContext, props: Props, namespacesRequired?: string[] | undefined): Promise<void> {
 async function injectNextI18NextConfigurations(context: GetServerSidePropsContext, props: Props, namespacesRequired?: string[] | undefined): Promise<void> {
-  const nextI18NextConfig = await getNextI18NextConfig(serverSideTranslations, context, namespacesRequired);
+  // preload all languages because of language lists in user setting
+  const nextI18NextConfig = await getNextI18NextConfig(serverSideTranslations, context, namespacesRequired, true);
   props._nextI18Next = nextI18NextConfig._nextI18Next;
   props._nextI18Next = nextI18NextConfig._nextI18Next;
 }
 }