Browse Source

feat(home): 首页增加语言选择并抽出中文文案

复用 library 的 x-language-switcher 放到首页右上角;语言链接在无名
路由下回退到当前 URL 追加 ?lang=。首页 hero 与四张卡片文案改走
resources/lang/*/home.php,中文的“佛典/圣典”统一为“典籍”。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F7AFuL8wggc2P543gPA88y
visuddhinanda 2 weeks ago
parent
commit
7af59c4b3d

+ 12 - 12
api-v13/app/Http/Controllers/PageIndexController.php

@@ -11,49 +11,49 @@ class PageIndexController extends Controller
             [
             [
                 'slug' => 'library',
                 'slug' => 'library',
                 'eyebrow' => 'Library',
                 'eyebrow' => 'Library',
-                'title' => '圣典文库',
-                'lead' => '三藏 · 义注 · 复注 · 字典',
+                'title' => __('home.cards.library.title'),
+                'lead' => __('home.cards.library.lead'),
                 'image' => 'library',
                 'image' => 'library',
                 'tint' => '#2E4A63',
                 'tint' => '#2E4A63',
                 'align' => 'start',
                 'align' => 'start',
                 'href' => '/library',
                 'href' => '/library',
-                'cta' => '进入文库',
+                'cta' => __('home.cards.library.cta'),
                 'available' => true,
                 'available' => true,
             ],
             ],
             [
             [
                 'slug' => 'course',
                 'slug' => 'course',
                 'eyebrow' => 'Course',
                 'eyebrow' => 'Course',
-                'title' => '次第课程',
-                'lead' => '从零开始,逐部研读',
+                'title' => __('home.cards.course.title'),
+                'lead' => __('home.cards.course.lead'),
                 'image' => 'course',
                 'image' => 'course',
                 'tint' => '#2A5257',
                 'tint' => '#2A5257',
                 'align' => 'end',
                 'align' => 'end',
                 'href' => '/library/course',
                 'href' => '/library/course',
-                'cta' => '开始学习',
+                'cta' => __('home.cards.course.cta'),
                 'available' => true,
                 'available' => true,
             ],
             ],
             [
             [
                 'slug' => 'workspace',
                 'slug' => 'workspace',
                 'eyebrow' => 'Workspace',
                 'eyebrow' => 'Workspace',
-                'title' => '翻译工作台',
-                'lead' => '术语、协作、校对、发布',
+                'title' => __('home.cards.workspace.title'),
+                'lead' => __('home.cards.workspace.lead'),
                 'image' => 'workspace',
                 'image' => 'workspace',
                 'tint' => '#2C4A3C',
                 'tint' => '#2C4A3C',
                 'align' => 'start',
                 'align' => 'start',
                 'href' => '/pcd-v2026/workspace',
                 'href' => '/pcd-v2026/workspace',
-                'cta' => '进入工作台',
+                'cta' => __('home.cards.workspace.cta'),
                 'available' => true,
                 'available' => true,
             ],
             ],
             [
             [
                 'slug' => 'development',
                 'slug' => 'development',
                 'eyebrow' => 'Development',
                 'eyebrow' => 'Development',
-                'title' => '二次开发',
-                'lead' => 'API · MCP · GitHub',
+                'title' => __('home.cards.development.title'),
+                'lead' => __('home.cards.development.lead'),
                 'image' => 'development',
                 'image' => 'development',
                 'tint' => '#4A4A48',
                 'tint' => '#4A4A48',
                 'align' => 'end',
                 'align' => 'end',
                 'href' => null,
                 'href' => null,
-                'cta' => '即将上线',
+                'cta' => __('home.cards.development.cta'),
                 'available' => false,
                 'available' => false,
             ],
             ],
         ];
         ];

+ 49 - 0
api-v13/resources/css/home.css

@@ -30,6 +30,55 @@
     background: var(--home-bg);
     background: var(--home-bg);
 }
 }
 
 
+/* 3.5 右上角语言选择(复用 x-language-switcher,改为浅底深字) */
+.home {
+    position: relative;
+}
+
+.home-lang {
+    position: absolute;
+    top: 1rem;
+    right: 1.5rem;
+    z-index: 10;
+}
+
+.home-lang .language-link,
+.home-lang .language-link:hover {
+    color: var(--home-text);
+}
+
+@media (max-width: 768px) {
+    .home-lang {
+        top: .75rem;
+        right: 1rem;
+    }
+
+    /* 组件移动端默认展开为静态列表,首页仍保持下拉 */
+    .home-lang .language-switcher {
+        width: auto;
+    }
+
+    .home-lang .language-dropdown {
+        position: absolute;
+        right: 0;
+        opacity: 0;
+        visibility: hidden;
+        transform: translateY(-10px);
+        background: rgba(0, 0, 0, .85);
+        -webkit-backdrop-filter: blur(10px);
+        backdrop-filter: blur(10px);
+        border: 1px solid rgba(255, 255, 255, .1);
+        margin-top: .5rem;
+        padding: .5rem 0;
+    }
+
+    .home-lang .language-switcher:hover .language-dropdown {
+        opacity: 1;
+        visibility: visible;
+        transform: translateY(0);
+    }
+}
+
 /* 4. 品牌 Hero */
 /* 4. 品牌 Hero */
 .home-hero {
 .home-hero {
     display: flex;
     display: flex;

+ 39 - 0
api-v13/resources/lang/en/home.php

@@ -0,0 +1,39 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Home Page Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | 首页(/)文案:品牌 hero 与四张分流卡片。
+    |
+    */
+
+    'title' => 'WikiPāli · Pali Buddhist Encyclopedia',
+    'hero_title' => 'WikiPāli',
+    'hero_lead' => 'Pali Buddhist Encyclopedia — step by step into the world of the Pali canon',
+    'cards' => [
+        'library' => [
+            'title' => 'Canon Library',
+            'lead' => 'Tipiṭaka · Commentary · Subcommentary · Dictionary',
+            'cta' => 'Enter the library',
+        ],
+        'course' => [
+            'title' => 'Graded Courses',
+            'lead' => 'Start from zero, study text by text',
+            'cta' => 'Start learning',
+        ],
+        'workspace' => [
+            'title' => 'Translation Workspace',
+            'lead' => 'Terms, collaboration, proofreading, publishing',
+            'cta' => 'Enter the workspace',
+        ],
+        'development' => [
+            'title' => 'Development',
+            'lead' => 'API · MCP · GitHub',
+            'cta' => 'Coming soon',
+        ],
+    ],
+];

+ 39 - 0
api-v13/resources/lang/my/home.php

@@ -0,0 +1,39 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Home Page Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | 首页(/)文案:品牌 hero 与四张分流卡片。
+    |
+    */
+
+    'title' => 'WikiPāli · ပါဠိဗုဒ္ဓစာပေ စွယ်စုံကျမ်း',
+    'hero_title' => 'WikiPāli',
+    'hero_lead' => 'ပါဠိဗုဒ္ဓစာပေ စွယ်စုံကျမ်း — အလွယ်မှ အခက်သို့ ပါဠိစာပေလောကထဲ ဝင်ရောက်ပါ',
+    'cards' => [
+        'library' => [
+            'title' => 'ပိဋကတ် စာကြည့်တိုက်',
+            'lead' => 'တိပိဋက · အဋ္ဌကထာ · ဋီကာ · အဘိဓာန်',
+            'cta' => 'စာကြည့်တိုက်သို့ ဝင်ရန်',
+        ],
+        'course' => [
+            'title' => 'အဆင့်ဆင့် သင်တန်း',
+            'lead' => 'အစမှစ၍ ကျမ်းတစ်စောင်ချင်း လေ့လာပါ',
+            'cta' => 'စတင်လေ့လာရန်',
+        ],
+        'workspace' => [
+            'title' => 'ဘာသာပြန် လုပ်ငန်းခွင်',
+            'lead' => 'ဝေါဟာရ၊ ပူးပေါင်းလုပ်ဆောင်မှု၊ စစ်ဆေးမှု၊ ထုတ်ဝေမှု',
+            'cta' => 'လုပ်ငန်းခွင်သို့ ဝင်ရန်',
+        ],
+        'development' => [
+            'title' => 'ဒုတိယအဆင့် ဖွံ့ဖြိုးရေး',
+            'lead' => 'API · MCP · GitHub',
+            'cta' => 'မကြာမီ လာမည်',
+        ],
+    ],
+];

+ 39 - 0
api-v13/resources/lang/si/home.php

@@ -0,0 +1,39 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Home Page Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | 首页(/)文案:品牌 hero 与四张分流卡片。
+    |
+    */
+
+    'title' => 'WikiPāli · පාලි බෞද්ධ විශ්වකෝෂය',
+    'hero_title' => 'WikiPāli',
+    'hero_lead' => 'පාලි බෞද්ධ විශ්වකෝෂය — පියවරෙන් පියවර පාලි ත්‍රිපිටක ලෝකයට',
+    'cards' => [
+        'library' => [
+            'title' => 'ග්‍රන්ථ පුස්තකාලය',
+            'lead' => 'ත්‍රිපිටකය · අට්ඨකථා · ටීකා · ශබ්දකෝෂය',
+            'cta' => 'පුස්තකාලයට පිවිසෙන්න',
+        ],
+        'course' => [
+            'title' => 'පියවරෙන් පියවර පාඨමාලා',
+            'lead' => 'මුල සිට, ග්‍රන්ථයෙන් ග්‍රන්ථය හදාරන්න',
+            'cta' => 'ඉගෙනීම අරඹන්න',
+        ],
+        'workspace' => [
+            'title' => 'පරිවර්තන වැඩපොළ',
+            'lead' => 'පාරිභාෂික වචන, සහයෝගය, පිරික්සුම, ප්‍රකාශනය',
+            'cta' => 'වැඩපොළට පිවිසෙන්න',
+        ],
+        'development' => [
+            'title' => 'ද්විතීයික සංවර්ධනය',
+            'lead' => 'API · MCP · GitHub',
+            'cta' => 'ඉක්මනින්',
+        ],
+    ],
+];

+ 39 - 0
api-v13/resources/lang/th/home.php

@@ -0,0 +1,39 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Home Page Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | 首页(/)文案:品牌 hero 与四张分流卡片。
+    |
+    */
+
+    'title' => 'WikiPāli · สารานุกรมพระไตรปิฎกบาลี',
+    'hero_title' => 'WikiPāli',
+    'hero_lead' => 'สารานุกรมพระไตรปิฎกบาลี — จากง่ายไปยาก เข้าสู่โลกแห่งพระบาลี',
+    'cards' => [
+        'library' => [
+            'title' => 'คลังพระคัมภีร์',
+            'lead' => 'พระไตรปิฎก · อรรถกถา · ฎีกา · พจนานุกรม',
+            'cta' => 'เข้าสู่คลังคัมภีร์',
+        ],
+        'course' => [
+            'title' => 'หลักสูตรตามลำดับ',
+            'lead' => 'เริ่มจากศูนย์ ศึกษาทีละคัมภีร์',
+            'cta' => 'เริ่มเรียน',
+        ],
+        'workspace' => [
+            'title' => 'พื้นที่ทำงานแปล',
+            'lead' => 'ศัพท์ การทำงานร่วมกัน การตรวจทาน การเผยแพร่',
+            'cta' => 'เข้าสู่พื้นที่ทำงาน',
+        ],
+        'development' => [
+            'title' => 'การพัฒนาต่อยอด',
+            'lead' => 'API · MCP · GitHub',
+            'cta' => 'เร็ว ๆ นี้',
+        ],
+    ],
+];

+ 39 - 0
api-v13/resources/lang/zh-Hans/home.php

@@ -0,0 +1,39 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Home Page Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | 首页(/)文案:品牌 hero 与四张分流卡片。
+    |
+    */
+
+    'title' => 'WikiPāli · 巴利典籍百科',
+    'hero_title' => 'WikiPāli',
+    'hero_lead' => '巴利典籍百科 —— 由浅入深,进入巴利典籍的世界',
+    'cards' => [
+        'library' => [
+            'title' => '典籍文库',
+            'lead' => '三藏 · 义注 · 复注 · 字典',
+            'cta' => '进入文库',
+        ],
+        'course' => [
+            'title' => '次第课程',
+            'lead' => '从零开始,逐部研读',
+            'cta' => '开始学习',
+        ],
+        'workspace' => [
+            'title' => '翻译工作台',
+            'lead' => '术语、协作、校对、发布',
+            'cta' => '进入工作台',
+        ],
+        'development' => [
+            'title' => '二次开发',
+            'lead' => 'API · MCP · GitHub',
+            'cta' => '即将上线',
+        ],
+    ],
+];

+ 1 - 1
api-v13/resources/lang/zh-Hans/library.php

@@ -141,7 +141,7 @@ return [
     // course (course/index.blade.php + course/history.blade.php)
     // course (course/index.blade.php + course/history.blade.php)
     'course' => '课程',
     'course' => '课程',
     'course_hero_title' => '课程',
     'course_hero_title' => '课程',
-    'course_hero_subtitle' => '跟随世界各地的巴利专家研读典',
+    'course_hero_subtitle' => '跟随世界各地的巴利专家研读典',
     'course_search_placeholder' => '搜索课程、讲师…',
     'course_search_placeholder' => '搜索课程、讲师…',
     'course_stat_total' => '公开课程',
     'course_stat_total' => '公开课程',
     'course_stat_open' => '开放报名',
     'course_stat_open' => '开放报名',

+ 39 - 0
api-v13/resources/lang/zh-Hant/home.php

@@ -0,0 +1,39 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Home Page Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | 首页(/)文案:品牌 hero 与四张分流卡片。
+    |
+    */
+
+    'title' => 'WikiPāli · 巴利典籍百科',
+    'hero_title' => 'WikiPāli',
+    'hero_lead' => '巴利典籍百科 —— 由淺入深,進入巴利典籍的世界',
+    'cards' => [
+        'library' => [
+            'title' => '典籍文庫',
+            'lead' => '三藏 · 義註 · 複註 · 字典',
+            'cta' => '進入文庫',
+        ],
+        'course' => [
+            'title' => '次第課程',
+            'lead' => '從零開始,逐部研讀',
+            'cta' => '開始學習',
+        ],
+        'workspace' => [
+            'title' => '翻譯工作台',
+            'lead' => '術語、協作、校對、發布',
+            'cta' => '進入工作台',
+        ],
+        'development' => [
+            'title' => '二次開發',
+            'lead' => 'API · MCP · GitHub',
+            'cta' => '即將上線',
+        ],
+    ],
+];

+ 1 - 1
api-v13/resources/lang/zh-Hant/library.php

@@ -138,7 +138,7 @@ return [
     // course (course/index.blade.php + course/history.blade.php)
     // course (course/index.blade.php + course/history.blade.php)
     'course' => '課程',
     'course' => '課程',
     'course_hero_title' => '課程',
     'course_hero_title' => '課程',
-    'course_hero_subtitle' => '跟隨世界各地的巴利專家研讀典',
+    'course_hero_subtitle' => '跟隨世界各地的巴利專家研讀典',
     'course_search_placeholder' => '搜尋課程、講師…',
     'course_search_placeholder' => '搜尋課程、講師…',
     'course_stat_total' => '公開課程',
     'course_stat_total' => '公開課程',
     'course_stat_open' => '開放報名',
     'course_stat_open' => '開放報名',

+ 11 - 1
api-v13/resources/views/components/language-switcher.blade.php

@@ -2,6 +2,16 @@
 $currentLocale = app()->getLocale();
 $currentLocale = app()->getLocale();
 $languages = config('mint.languages');
 $languages = config('mint.languages');
 $currentLanguage = $languages[$currentLocale] ?? 'en';
 $currentLanguage = $languages[$currentLocale] ?? 'en';
+// 首页等无名路由用当前 URL 追加 ?lang= ,具名路由仍按路由参数生成,保持原有链接形式
+$localeUrl = function (string $locale) {
+    $routeName = Route::currentRouteName();
+
+    if ($routeName) {
+        return route($routeName, array_merge(request()->route()->parameters(), ['lang' => $locale]));
+    }
+
+    return request()->fullUrlWithQuery(['lang' => $locale]);
+};
 @endphp
 @endphp
 
 
 <div class="language-switcher">
 <div class="language-switcher">
@@ -20,7 +30,7 @@ $currentLanguage = $languages[$currentLocale] ?? 'en';
     <ul class="language-dropdown">
     <ul class="language-dropdown">
         @foreach ($languages as $locale => $language)
         @foreach ($languages as $locale => $language)
         <li>
         <li>
-            <a href="{{ route(Route::currentRouteName(), array_merge(request()->route()->parameters(), ['lang' => $locale])) }}"
+            <a href="{{ $localeUrl($locale) }}"
                 class="language-dropdown-item {{ $locale === $currentLocale ? 'active' : '' }}">
                 class="language-dropdown-item {{ $locale === $currentLocale ? 'active' : '' }}">
                 {{ $language }}
                 {{ $language }}
             </a>
             </a>

+ 1 - 1
api-v13/resources/views/layouts/base.blade.php

@@ -9,7 +9,7 @@
     <meta charset="utf-8" />
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
     <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
     <meta http-equiv="X-UA-Compatible" content="ie=edge" />
     <meta http-equiv="X-UA-Compatible" content="ie=edge" />
-    <title>@yield('title', 'WikiPāli · 巴利典百科')</title>
+    <title>@yield('title', 'WikiPāli · 巴利典百科')</title>
 
 
     {{-- 基础样式由子布局通过 @vite 注入 --}}
     {{-- 基础样式由子布局通过 @vite 注入 --}}
     @stack('styles')
     @stack('styles')

+ 8 - 3
api-v13/resources/views/pages/home.blade.php

@@ -4,7 +4,7 @@
 --}}
 --}}
 @extends('layouts.base')
 @extends('layouts.base')
 
 
-@section('title', 'WikiPāli · 巴利佛典百科')
+@section('title', __('home.title'))
 
 
 @push('styles')
 @push('styles')
 @vite(['resources/css/home.css'])
 @vite(['resources/css/home.css'])
@@ -15,10 +15,15 @@
 @section('page')
 @section('page')
 <main class="home">
 <main class="home">
 
 
+    {{-- 右上角语言选择,复用 library 的切换组件 --}}
+    <div class="home-lang">
+        <x-language-switcher />
+    </div>
+
     {{-- 品牌 Hero:站名 + 一行说明,居中 --}}
     {{-- 品牌 Hero:站名 + 一行说明,居中 --}}
     <header class="home-hero">
     <header class="home-hero">
-        <h1 class="home-hero__title">WikiPāli</h1>
-        <p class="home-hero__lead">巴利佛典百科 —— 由浅入深,进入巴利圣典的世界</p>
+        <h1 class="home-hero__title">{{ __('home.hero_title') }}</h1>
+        <p class="home-hero__lead">{{ __('home.hero_lead') }}</p>
     </header>
     </header>
 
 
     {{-- 四张通栏卡片,纵向排列 --}}
     {{-- 四张通栏卡片,纵向排列 --}}

+ 2 - 2
api-v13/resources/views/typhoon.blade.php

@@ -159,13 +159,13 @@ Read the documentation
 <div class="xl:container xl:mx-auto md:px-6 px-4">
 <div class="xl:container xl:mx-auto md:px-6 px-4">
 <div class="w-5/6 md:w-3/4 lg:w-2/3 xl:w-1/2 text-center mx-auto mb-16">
 <div class="w-5/6 md:w-3/4 lg:w-2/3 xl:w-1/2 text-center mx-auto mb-16">
 <div class="text-xs md:text-sm opacity-75 font-semibold uppercase tracking-wide text-gray-700 dark:text-gray-300">
 <div class="text-xs md:text-sm opacity-75 font-semibold uppercase tracking-wide text-gray-700 dark:text-gray-300">
-让学习典变得更容易
+让学习典变得更容易
 </div>
 </div>
 <h2 class="mt-1 tracking-tight leading-tighter text-2xl sm:text-3xl md:text-4xl lg:text-5xl font-extrabold text-gray-900 dark:text-gray-100">
 <h2 class="mt-1 tracking-tight leading-tighter text-2xl sm:text-3xl md:text-4xl lg:text-5xl font-extrabold text-gray-900 dark:text-gray-100">
 我们的愿景
 我们的愿景
 </h2>
 </h2>
 <div class="mt-3 text-base md:text-lg lg:text-xl prose">
 <div class="mt-3 text-base md:text-lg lg:text-xl prose">
-<p>打造一个公共的巴利典学习平台。</p>
+<p>打造一个公共的巴利典学习平台。</p>
 </div>
 </div>
 </div>
 </div>
 <div class="grid md:grid-cols-2 xl:grid-cols-3 gap-y-8 gap-x-8 ">
 <div class="grid md:grid-cols-2 xl:grid-cols-3 gap-y-8 gap-x-8 ">