From 75a9713ed2f5723b34318744614cd8b55cfb09f2 Mon Sep 17 00:00:00 2001 From: nasser Date: Thu, 15 Jul 2021 19:24:46 +0430 Subject: [PATCH] add translation to docs --- docs/en/index.html | 18 ++++++++- docs/index.html | 53 +++++++++++++++++---------- src/Lang/az.php | 77 +++++++++++++++++++++++++++++++++++++++ src/Lang/haz.php | 77 +++++++++++++++++++++++++++++++++++++++ src/Traits/Translator.php | 6 ++- 5 files changed, 209 insertions(+), 22 deletions(-) create mode 100644 src/Lang/az.php create mode 100644 src/Lang/haz.php diff --git a/docs/en/index.html b/docs/en/index.html index 9399621..d1cef0f 100644 --- a/docs/en/index.html +++ b/docs/en/index.html @@ -566,6 +566,22 @@ array:2 [ 0 => "The expire datetime must be a Jalali datetime before 1397/02/16 12:10:00." ] ] + + + +

Traslation

+

You can show weekdays, months , messages in the languages available in Verta To view supported languages, go to the folder langs

+

To set locale, use the following command

+
+Verta::setLocale('fa');
+
+

To get current locale, use the following command

+
+Verta::getLocale(); // fa
+
+

To reset locale to fa, use the following command

+
+Verta::resetLocale();
 
@@ -574,7 +590,7 @@ array:2 [ diff --git a/docs/index.html b/docs/index.html index 98db2ac..582e072 100644 --- a/docs/index.html +++ b/docs/index.html @@ -67,13 +67,13 @@
// config/app.php
 'providers' => [
-...
-Hekmatinasser\Verta\Laravel\VertaServiceProvider::class,
+    ...
+    Hekmatinasser\Verta\Laravel\VertaServiceProvider::class,
 ],
 
 'alias' => [
-...
-'Verta' => Hekmatinasser\Verta\Verta::class,
+    ...
+    'Verta' => Hekmatinasser\Verta\Verta::class,
 ]

نحوه استفاده

در بالای هر فایل خود از کلاس ورتا استفاده میکند، از دستور زیر استفاده کنید

@@ -415,7 +415,7 @@ return $v1->isFriday(); // false

اعتبار سنجی

شما می توانید با اعتبار سنجی لاراول تاریخ های شمسی درون فرم های خود استفاده کنید

-

شما باید پیام های خطا برای اعتبار سنجی خود در در مسیر فایل های ترجمه خود اضافه کنیدبرای نمونه کد هایی که درون پکیج برای پیام خطا وجود دارد در فایل ترجمه خود قرار دهیدبرای مثال در فایل ترجمه پیام خطا به آرایه عبارات زیر را اضافه کنید

+

شما باید پیام های خطا برای اعتبار سنجی خود در در مسیر فایل های ترجمه خود اضافه کنید ارور های ترجمه شده برای زبان های قابل پشتیبانی در زبان ها مراجعه کنید قرار دارد .برای نمونه کد هایی که درون پکیج برای پیام خطا وجود دارد در فایل ترجمه خود قرار دهیدبرای مثال در فایل ترجمه پیام خطا به آرایه عبارات زیر را اضافه کنید

 'jdate' => ':attribute تاریخ شمسی معتبر نمی باشد.',
 'jdate_equal' => ':attribute تاریخ شمسی برابر :date نمی باشد.',
@@ -433,8 +433,8 @@ return $v1->isFriday(); // false
 'jdatetime_before_equal' => ':attribute تاریخ و زمان شمسی باید قبل یا برابر از :date باشد.',
 
 'attributes' => [
-'start_date' => 'تاریخ شروع',
-'expire_datetime' => 'تاریخ انقضا',
+    'start_date' => 'تاریخ شروع',
+    'expire_datetime' => 'تاریخ انقضا',
 ],
 

قوانین اعتبار سنجی

@@ -550,12 +550,12 @@ return $v1->isFriday(); // false

میتوانید با ترکیب قوانین تاریخ را بین دو محدوده بررسی کنید

 $validate = Validator::make([
-'start_date' => '1389/01/31',
-'expire_datetime' => '1397/02/16 12:10:00',
+    'start_date' => '1389/01/31',
+    'expire_datetime' => '1397/02/16 12:10:00',
 ],
 [
-'start_date' => 'required|jdate:Y/m/d|jdate_after:1388/01/01,Y/m/d|jdate_before:1390/01/01',
-'expire_datetime' => 'required|jdatetime|jdatetime_after:1397/02/16 12:09:50,Y/m/d H:i:s|jdatetime_before:1397/02/16 12:11:00',
+    'start_date' => 'required|jdate:Y/m/d|jdate_after:1388/01/01,Y/m/d|jdate_before:1390/01/01',
+    'expire_datetime' => 'required|jdatetime|jdatetime_after:1397/02/16 12:09:50,Y/m/d H:i:s|jdatetime_before:1397/02/16 12:11:00',
 ]);
 
 if ($validate->fails()) {
@@ -564,16 +564,31 @@ dd($validate->messages()->toArray());
 
 //output
 array:2 [
-"start_date" => array:1 [
-0 => "تاریخ شروع تاریخ شمسی باید قبل از ۱۳۹۰/۰۱/۰۱ باشد."
-]
-"expire_datetime" => array:1 [
-0 => "تاریخ انقضا تاریخ و زمان شمسی باید قبل از ۱۳۹۷/۰۲/۱۶ ۱۲:۱۰:۰۰ باشد."
-]
+    "start_date" => array:1 [
+        0 => "تاریخ شروع تاریخ شمسی باید قبل از ۱۳۹۰/۰۱/۰۱ باشد."
+    ]
+    "expire_datetime" => array:1 [
+        0 => "تاریخ انقضا تاریخ و زمان شمسی باید قبل از ۱۳۹۷/۰۲/۱۶ ۱۲:۱۰:۰۰ باشد."
+    ]
 ]
 
-

اعتبار سنجی

+

زبان ها

+

شما میتوانید ایام و ماه ها و پیام را به زبان های موجود در ورتا نمایش دهید برای مشاهده زبان ها پشتیبانی می شود به پوشه زیر مشاهده + زبان ها مراجعه کنید

+

برای تعیین زبان پیام های از دستور زیر استفاده کنید

+
+Verta::setLocale('fa');
+
+

برای دریافت زبان جاری پیام های از دستور زیر استفاده کنید

+
+Verta::getLocale(); // fa
+
+

برای ریست کردن زبان به فارسی از دستور زیر استفاده کنید

+
+Verta::resetLocale();
+
+

برای افزودن زبان های دیگر نمونه فایل های موجود را برای ادغام با پروژه ارسال کنید

@@ -582,7 +597,7 @@ array:2 [ diff --git a/src/Lang/az.php b/src/Lang/az.php new file mode 100644 index 0000000..cfe6519 --- /dev/null +++ b/src/Lang/az.php @@ -0,0 +1,77 @@ + [ + '0' => '۰', + '1' => '۱', + '2' => '۲', + '3' => '۳', + '4' => '۴', + '5' => '۵', + '6' => '۶', + '7' => '۷', + '8' => '۸', + '9' => '۹', + ], + 'year_months' => [ + '1' => 'آغلارگولر', + '2' => 'گولن', + '3' => 'قیزاران', + '4' => 'قورا پیشیرن', + '5' => 'قویروق دوغان', + '6' => 'زومار', + '7' => 'خزل', + '8' => 'قیروو', + '9' => 'آذر', + '10' => 'چیلله', + '11' => 'دوندوران', + '12' => 'بایرام', + ], + 'weekdays' => [ + '1' => 'شنبه', + '2' => 'یکشنبه', + '3' => 'دوشنبه', + '4' => 'سه شنبه', + '5' => 'چهارشنبه', + '6' => 'پنج شنبه', + '7' => 'جمعه', + ], + 'date_units' => [ + 'second' => 'ثانیه', + 'mintue' => 'دقیقه', + 'hour' => 'ساعت', + 'day' => 'روز', + 'week' => 'هفته', + 'month' => 'ماه', + 'yaer' => 'سال', + 'decade' => 'دهه', + 'century' => 'قرن' + ], + 'phrase' => [ + 'am' => 'ق ظ', + 'pm' => 'ب ظ', + 'ante_meridiem' => 'قبل از ظهر', + 'post_meridiem' => 'بعد از ظهر', + 'th' => 'ام', + 'ago' => 'قبل', + 'now' => 'الان', + 'later' => 'بعد', + ], + 'validation' => [ + 'jdate' => ':attribute' . ' تاریخ شمسی معتبر نمی باشد.', + 'jdate_equal' => ':attribute' . ' تاریخ شمسی برابر ' . ':date' . ' نمی باشد.', + 'jdate_not_equal' => ':attribute' . ' تاریخ شمسی نامساوی ' . ':date' . ' نمی باشد.', + 'jdatetime' => ':attribute' . ' تاریخ و زمان شمسی معتبر نمی باشد.', + 'jdatetime_equal' => ':attribute' . ' تاریخ و زمان شمسی مساوی ' . ':date' . ' نمی باشد.', + 'jdatetime_not_equal' => ':attribute' . ' تاریخ و زمان شمسی نامساوی ' . ':date' . ' نمی باشد.', + 'jdate_after' => ':attribute' . ' تاریخ شمسی باید بعد از ' . ':date' . ' باشد.', + 'jdate_after_equal' => ':attribute' . ' تاریخ شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', + 'jdatetime_after' => ':attribute' . ' تاریخ و زمان شمسی باید بعد از ' . ':date' . ' باشد.', + 'jdatetime_after_equal' => ':attribute' . ' تاریخ و زمان شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', + 'jdate_before' => ':attribute' . ' تاریخ شمسی باید قبل از ' . ':date' . ' باشد.', + 'jdate_before_equal' => ':attribute' . ' تاریخ شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', + 'jdatetime_before' => ':attribute' . ' تاریخ و زمان شمسی باید قبل از ' . ':date' . ' باشد.', + 'jdatetime_before_equal' => ':attribute' . ' تاریخ و زمان شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', + ] +]; + diff --git a/src/Lang/haz.php b/src/Lang/haz.php new file mode 100644 index 0000000..cc8d370 --- /dev/null +++ b/src/Lang/haz.php @@ -0,0 +1,77 @@ + [ + '0' => '۰', + '1' => '۱', + '2' => '۲', + '3' => '۳', + '4' => '۴', + '5' => '۵', + '6' => '۶', + '7' => '۷', + '8' => '۸', + '9' => '۹', + ], + 'year_months' => [ + '1' => 'اورال', + '2' => 'اید', + '3' => 'بررید', + '4' => 'سرتایستو', + '5' => 'چیله تایستو', + '6' => 'آخیر تایستو', + '7' => 'تخم ریز', + '8' => 'برگ ریز', + '9' => 'چیله زمستو', + '10' => 'بامو', + '11' => 'سیاه بار', + '12' => 'نجیر', + ], + 'weekdays' => [ + '1' => 'شنبه', + '2' => 'یکشنبه', + '3' => 'دوشنبه', + '4' => 'سه شنبه', + '5' => 'چهارشنبه', + '6' => 'پنج شنبه', + '7' => 'جمعه', + ], + 'date_units' => [ + 'second' => 'ثانیه', + 'mintue' => 'دقیقه', + 'hour' => 'ساعت', + 'day' => 'روز', + 'week' => 'هفته', + 'month' => 'ماه', + 'yaer' => 'سال', + 'decade' => 'دهه', + 'century' => 'قرن' + ], + 'phrase' => [ + 'am' => 'ق ظ', + 'pm' => 'ب ظ', + 'ante_meridiem' => 'قبل از ظهر', + 'post_meridiem' => 'بعد از ظهر', + 'th' => 'ام', + 'ago' => 'قبل', + 'now' => 'الان', + 'later' => 'بعد', + ], + 'validation' => [ + 'jdate' => ':attribute' . ' تاریخ شمسی معتبر نمی باشد.', + 'jdate_equal' => ':attribute' . ' تاریخ شمسی برابر ' . ':date' . ' نمی باشد.', + 'jdate_not_equal' => ':attribute' . ' تاریخ شمسی نامساوی ' . ':date' . ' نمی باشد.', + 'jdatetime' => ':attribute' . ' تاریخ و زمان شمسی معتبر نمی باشد.', + 'jdatetime_equal' => ':attribute' . ' تاریخ و زمان شمسی مساوی ' . ':date' . ' نمی باشد.', + 'jdatetime_not_equal' => ':attribute' . ' تاریخ و زمان شمسی نامساوی ' . ':date' . ' نمی باشد.', + 'jdate_after' => ':attribute' . ' تاریخ شمسی باید بعد از ' . ':date' . ' باشد.', + 'jdate_after_equal' => ':attribute' . ' تاریخ شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', + 'jdatetime_after' => ':attribute' . ' تاریخ و زمان شمسی باید بعد از ' . ':date' . ' باشد.', + 'jdatetime_after_equal' => ':attribute' . ' تاریخ و زمان شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', + 'jdate_before' => ':attribute' . ' تاریخ شمسی باید قبل از ' . ':date' . ' باشد.', + 'jdate_before_equal' => ':attribute' . ' تاریخ شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', + 'jdatetime_before' => ':attribute' . ' تاریخ و زمان شمسی باید قبل از ' . ':date' . ' باشد.', + 'jdatetime_before_equal' => ':attribute' . ' تاریخ و زمان شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', + ] +]; + diff --git a/src/Traits/Translator.php b/src/Traits/Translator.php index 2d4c65c..52f624a 100644 --- a/src/Traits/Translator.php +++ b/src/Traits/Translator.php @@ -35,8 +35,10 @@ trait Translator */ public static function setLocale($locale) { - static::$locale = $locale; - static::loadMessages($locale); + if($messages = static::loadMessages($locale)) { + static::$locale = $locale; + } + return $messages; } /**