Browse Source

tested multi language

mx 3 năm trước cách đây
mục cha
commit
3a5d097111

+ 3 - 1
app/controller/Index.php

@@ -15,7 +15,9 @@ class Index
 
     public function view(Request $request)
     {
-        return view('index/view', ['name' => 'webman']);
+        locale('en');
+        $hello = trans('hello');
+        return view('index/view', ['hello' => $hello]);
     }
 
     public function json(Request $request)

+ 1 - 1
app/view/index/view.html

@@ -9,6 +9,6 @@
 
 </head>
 <body>
-hello <?=htmlspecialchars($name)?>
+<?=htmlspecialchars($hello)?>
 </body>
 </html>

+ 2 - 1
composer.json

@@ -34,7 +34,8 @@
     "illuminate/redis": "^8.83",
     "symfony/cache": "^5.4",
     "webman/console": "^1.0",
-    "webman/redis-queue": "^1.1"
+    "webman/redis-queue": "^1.1",
+    "symfony/translation": "^5.4"
   },
   "suggest": {
     "ext-event": "For better performance. "

+ 1 - 1
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "f716421c6bb3c5add8c4fd4b6c47eba9",
+    "content-hash": "c162176b42a8c9d138c2a6bfa701ceb3",
     "packages": [
         {
             "name": "cakephp/core",

+ 5 - 0
resource/translations/en/messages.php

@@ -0,0 +1,5 @@
+<?php
+
+return [
+	'hello' => 'Hello webman.',
+];

+ 5 - 0
resource/translations/zh_CN/messages.php

@@ -0,0 +1,5 @@
+<?php
+
+return [
+	'hello' => '你好,玩儿不满',
+];