Skip to content

Commit afb3040

Browse files
committed
feat: support laravel 6 to 12
1 parent 8153e37 commit afb3040

File tree

6 files changed

+73
-51
lines changed

6 files changed

+73
-51
lines changed

README.md

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
This package provides Persian language files for Laravel.
44

5-
## Requirements
6-
7-
- PHP >= 7.0
8-
- Laravel >= 5.0
5+
- Support Laravel 6 to 12
96

107
## Installation
118

@@ -22,46 +19,24 @@ composer require sadegh19b/laravel-persian-lang
2219
If you prefer not to use Composer, you can manually copy the language files:
2320

2421
1. Download or clone this repository
25-
2. Copy the `fa` folder from `lang/` to your Laravel application's `resources/lang/` directory
22+
2. Copy the `fa` folder from `lang/` to your Laravel application's `lang/` directory
2623
3. The language files will be available in your application
2724

28-
## Configuration
29-
30-
### Option 1: Automatic Registration (Laravel 5.5+)
31-
32-
For Laravel 5.5 and above, the service provider will be automatically registered by Laravel's package discovery.
33-
34-
### Option 2: Manual Registration (Laravel 5.0-5.4)
35-
36-
If you're using Laravel 5.0-5.4, you need to manually register the service provider in `config/app.php`:
37-
38-
```php
39-
'providers' => [
40-
// Other Service Providers...
41-
Sadegh19b\PersianLang\PersianLangServiceProvider::class,
42-
],
43-
```
44-
4525
## Usage
4626

4727
### 1. Publishing Language Files
4828

49-
#### For Laravel 5.3 and above:
50-
```bash
51-
php artisan vendor:publish --tag=persian-lang
52-
```
29+
Run the following command to publish the language files:
5330

54-
#### For Laravel 5.0-5.2:
55-
The language files will be automatically published when the service provider is registered. If you need to republish the files, you can run:
5631
```bash
57-
php artisan vendor:publish
32+
php artisan vendor:publish --tag=persian-lang
5833
```
5934

60-
This will copy the language files to `resources/lang/fa/` in your application. You can then modify them as needed.
35+
This will copy the language files to `lang/fa/` in your application. You can then modify them as needed.
6136

6237
### 2. Setting the Language
6338

64-
To use Persian as your application's language, you should set the locale in your `config/app.php` file:
39+
To use Persian as your application's language, set the locale in your `config/app.php` file:
6540

6641
```php
6742
'locale' => 'fa',

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"illuminate/support": "^5.0"
13+
"illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0"
1414
},
1515
"autoload": {
1616
"psr-4": {

lang/fa/auth.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
'failed' => 'این مشخصات با اطلاعات ما مطابقت ندارد.',
17+
'password' => 'رمز عبور اشتباه است.',
1718
'throttle' => 'دفعات تلاش شما بیش از حد مجاز است، لطفاً :seconds ثانیه دیگر دوباره تلاش کنید.',
1819

1920
];

lang/fa/passwords.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/*
66
|--------------------------------------------------------------------------
7-
| Password Reminder Language Lines
7+
| Password Reset Language Lines
88
|--------------------------------------------------------------------------
99
|
1010
| The following language lines are the default lines which match reasons
@@ -13,10 +13,10 @@
1313
|
1414
*/
1515

16-
'password' => 'رمز عبور باید حداقل ۶ کاراکتر باشد و با تکرار آن مطابقت داشته باشد.',
17-
'user' => 'کاربری با این آدرس ایمیل یافت نشد.',
18-
'token' => 'توکن بازیابی رمز عبور نامعتبر است.',
19-
'sent' => 'لینک بازیابی رمز عبور به ایمیل شما ارسال شد.',
2016
'reset' => 'رمز عبور شما بازیابی شد.',
17+
'sent' => 'لینک بازیابی رمز عبور به ایمیل شما ارسال شد.',
18+
'throttled' => 'لطفاً قبل از تلاش مجدد کمی صبر کنید.',
19+
'token' => 'توکن بازیابی رمز عبور نامعتبر است.',
20+
'user' => 'کاربری با این آدرس ایمیل یافت نشد.',
2121

2222
];

lang/fa/validation.php

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
*/
1515

1616
'accepted' => 'فیلد :attribute باید پذیرفته شده باشد.',
17+
'accepted_if' => 'فیلد :attribute وقتی که :other برابر با :value است، باید پذیرفته شود.',
1718
'active_url' => 'فیلد :attribute باید یک URL معتبر باشد.',
1819
'after' => 'فیلد :attribute باید تاریخی بعد از :date باشد.',
1920
'after_or_equal' => 'فیلد :attribute باید تاریخی بعد یا برابر با :date باشد.',
2021
'alpha' => 'فیلد :attribute باید فقط شامل حروف الفبای لاتین باشد.',
2122
'alpha_dash' => 'فیلد :attribute باید فقط شامل حروف الفبای لاتین، اعداد لاتین، خط تیره و زیرخط باشد.',
2223
'alpha_num' => 'فیلد :attribute باید فقط شامل حروف الفبا و اعداد لاتین باشد.',
24+
'any_of' => 'فیلد :attribute معتبر نیست.',
2325
'array' => 'فیلد :attribute باید آرایه باشد.',
26+
'ascii' => 'فیلد :attribute باید فقط شامل کاراکترها و نمادهای الفبایی تک بایتی (ASCII) باشد.',
2427
'before' => 'فیلد :attribute باید تاریخی قبل از :date باشد.',
2528
'before_or_equal' => 'فیلد :attribute باید تاریخی قبل یا برابر با :date باشد.',
2629
'between' => [
@@ -30,17 +33,26 @@
3033
'string' => 'فیلد :attribute باید بین :min و :max کاراکتر باشد.',
3134
],
3235
'boolean' => 'فیلد :attribute باید درست (True) یا نادرست (False) باشد.',
36+
'can' => 'فیلد :attribute حاوی یک مقدار غیرمجاز است.',
3337
'confirmed' => 'فیلد :attribute با فیلد تکرار مطابقت ندارد.',
38+
'contains' => 'فیلد :attribute فاقد یک مقدار الزامی است.',
39+
'current_password' => 'رمز عبور فعلی اشتباه است.',
3440
'date' => 'فیلد :attribute باید یک تاریخ معتبر باشد.',
3541
'date_equals' => 'فیلد :attribute باید برابر با :date باشد.',
3642
'date_format' => 'فیلد :attribute با الگوی :format مطابقت ندارد.',
43+
'decimal' => 'فیلد :attribute باید دارای :decimal رقم اعشار باشد.',
44+
'declined' => 'فیلد :attribute باید رد شود.',
45+
'declined_if' => 'فیلد :attribute وقتی :other برابر :value است، باید رد شود.',
3746
'different' => 'فیلد :attribute و :other باید از یکدیگر متفاوت باشند.',
3847
'digits' => 'فیلد :attribute باید :digits رقم باشد.',
3948
'digits_between' => 'فیلد :attribute باید بین :min و :max رقم باشد.',
4049
'dimensions' => 'ابعاد تصویر فیلد :attribute نامعتبر است.',
4150
'distinct' => 'فیلد :attribute مقدار تکراری دارد.',
51+
'doesnt_end_with' => 'فیلد :attribute نباید با یکی از موارد (:values) به پایان برسد.',
52+
'doesnt_start_with' => 'فیلد :attribute نباید با یکی از موارد (:values) شروع شود.',
4253
'email' => 'فیلد :attribute باید یک ایمیل معتبر باشد.',
4354
'ends_with' => 'فیلد :attribute باید با یکی از موارد (:values) به پایان برسد.',
55+
'enum' => ':attribute انتخاب شده نامعتبر است.',
4456
'exists' => ':attribute انتخاب شده، معتبر نیست.',
4557
'extensions' => 'فیلد :attribute باید یکی از پسوندهای (:values) را داشته باشد.',
4658
'file' => 'فیلد :attribute باید یک فایل باشد.',
@@ -57,6 +69,7 @@
5769
'numeric' => 'فیلد :attribute باید بزرگتر یا برابر با :value باشد.',
5870
'string' => 'فیلد :attribute باید بیشتر یا برابر با :value کاراکتر باشد.',
5971
],
72+
'hex_color' => 'فیلد :attribute باید یک کد رنگ هگزادسیمال معتبر باشد.',
6073
'image' => 'فیلد :attribute باید یک تصویر باشد.',
6174
'in' => ':attribute انتخاب شده، معتبر نیست.',
6275
'in_array' => 'فیلد :attribute باید در :other وجود داشته باشد.',
@@ -65,6 +78,8 @@
6578
'ipv4' => 'فیلد :attribute باید یک آدرس IPv4 معتبر باشد.',
6679
'ipv6' => 'فیلد :attribute باید یک آدرس IPv6 معتبر باشد.',
6780
'json' => 'فیلد :attribute باید یک رشته JSON معتبر باشد.',
81+
'list' => 'فیلد :attribute باید یک لیست باشد.',
82+
'lowercase' => 'فیلد :attribute باید با حروف کوچک باشد.',
6883
'lt' => [
6984
'array' => 'فیلد :attribute باید کمتر از :value آیتم داشته باشد.',
7085
'file' => 'فیلد :attribute باید کوچکتر از :value کیلوبایت باشد.',
@@ -77,12 +92,14 @@
7792
'numeric' => 'فیلد :attribute باید کوچکتر یا برابر با :value باشد.',
7893
'string' => 'فیلد :attribute باید کمتر یا برابر با :value کاراکتر باشد.',
7994
],
95+
'mac_address' => 'فیلد :attribute باید یک آدرس MAC معتبر باشد.',
8096
'max' => [
8197
'array' => 'فیلد :attribute نباید بیشتر از :max آیتم داشته باشد.',
8298
'file' => 'فیلد :attribute نباید بزرگتر از :max کیلوبایت باشد.',
8399
'numeric' => 'فیلد :attribute نباید بزرگتر از :max باشد.',
84100
'string' => 'فیلد :attribute نباید بیشتر از :max کاراکتر باشد.',
85101
],
102+
'max_digits' => 'فیلد :attribute نباید بیشتر از :max رقم داشته باشد.',
86103
'mimes' => 'فیلد :attribute باید یکی از فرمت های :values باشد.',
87104
'mimetypes' => 'فیلد :attribute باید یکی از فرمت های :values باشد.',
88105
'min' => [
@@ -91,12 +108,40 @@
91108
'numeric' => 'فیلد :attribute نباید کوچکتر از :min باشد.',
92109
'string' => 'فیلد :attribute نباید کمتر از :min کاراکتر باشد.',
93110
],
111+
'min_digits' => 'فیلد :attribute باید حداقل :min رقم داشته باشد.',
112+
'missing' => 'فیلد :attribute باید خالی باشد.',
113+
'missing_if' => 'فیلد :attribute باید وقتی :other برابر با :value است، خالی باشد.',
114+
'missing_unless' => 'فیلد :attribute باید خالی باشد، مگر اینکه :other برابر با :value باشد.',
115+
'missing_with' => 'فیلد :attribute وقتی که :values موجود است، باید خالی باشد.',
116+
'missing_with_all' => 'فیلد :attribute وقتی که همه :values موجود باشند، باید خالی باشد.',
117+
'multiple_of' => 'فیلد :attribute باید یکی از :value باشد.',
94118
'not_in' => ':attribute انتخاب شده، معتبر نیست.',
95119
'not_regex' => 'فرمت فیلد :attribute نامعتبر است.',
96120
'numeric' => 'فیلد :attribute باید عدد باشد.',
121+
'password' => [
122+
'letters' => 'فیلد :attribute باید حداقل شامل یک حرف باشد.',
123+
'mixed' => 'فیلد :attribute باید حداقل شامل یک حرف بزرگ و یک حرف کوچک باشد.',
124+
'numbers' => 'فیلد :attribute باید حداقل شامل یک عدد باشد.',
125+
'symbols' => 'فیلد :attribute باید حداقل شامل یک نماد باشد.',
126+
'uncompromised' => ':attribute داده شده در نشت داده‌ها پیدا شده است. لطفاً یک :attribute متفاوت انتخاب کنید.',
127+
],
128+
'present' => 'فیلد :attribute باید وجود داشته باشد.',
129+
'present_if' => 'فیلد :attribute وقتی :other برابر با :value است، باید وجود داشته باشد.',
130+
'present_unless' => 'فیلد :attribute باید وجود داشته باشد، مگر اینکه :other برابر با :value باشد.',
131+
'present_with' => 'فیلد :attribute وقتی که :values وجود دارد، باید وجود داشته باشد.',
132+
'present_with_all' => 'فیلد :attribute وقتی که همه :values وجود دارند، باید وجود داشته باشد.',
133+
'prohibited' => 'فیلد :attribute ممنوع است.',
134+
'prohibited_if' => 'فیلد :attribute وقتی که :other برابر با :value است، ممنوع است.',
135+
'prohibited_if_accepted' => 'فیلد :attribute وقتی که :other پذیرفته شده باشد، ممنوع است.',
136+
'prohibited_if_declined' => 'فیلد :attribute وقتی که :other رد شده باشد، ممنوع است.',
137+
'prohibited_unless' => 'فیلد :attribute ممنوع است، مگر اینکه :other در :values موجود باشد.',
138+
'prohibits' => 'فیلد :attribute اجازه حضور :other را نمی‌دهد.',
97139
'regex' => 'فرمت :attribute معتبر نیست.',
98140
'required' => 'فیلد :attribute الزامی است.',
141+
'required_array_keys' => 'فیلد :attribute باید شامل ورودی‌های (:values) باشد.',
99142
'required_if' => 'وقتی که :other برابر با :value است، فیلد :attribute الزامی است.',
143+
'required_if_accepted' => 'فیلد :attribute وقتی که :other پذیرفته شده باشد، الزامی است.',
144+
'required_if_declined' => 'فیلد :attribute وقتی که :other رد شده باشد، الزامی است.',
100145
'required_unless' => 'فیلد :attribute الزامی است، مگر اینکه :other در :values موجود باشد.',
101146
'required_with' => 'در صورت وجود :values، فیلد :attribute الزامی است.',
102147
'required_with_all' => 'در صورت وجود :values، فیلد :attribute الزامی است.',
@@ -114,7 +159,9 @@
114159
'timezone' => 'فیلد :attribute باید یک منطقه زمانی معتبر باشد.',
115160
'unique' => 'فیلد :attribute قبلاً انتخاب شده است.',
116161
'uploaded' => 'آپلود :attribute با خطا مواجه شد.',
162+
'uppercase' => 'فیلد :attribute باید با حروف بزرگ باشد.',
117163
'url' => 'فیلد :attribute باید یک URL معتبر باشد.',
164+
'ulid' => 'فیلد :attribute باید یک ULID معتبر باشد.',
118165
'uuid' => 'فیلد :attribute باید یک UUID معتبر باشد.',
119166

120167
/*
@@ -139,9 +186,9 @@
139186
| Custom Validation Attributes
140187
|--------------------------------------------------------------------------
141188
|
142-
| The following language lines are used to swap attribute place-holders
143-
| with something more reader friendly such as E-Mail Address instead
144-
| of "email". This simply helps us make messages a little cleaner.
189+
| The following language lines are used to swap our attribute placeholder
190+
| with something more reader friendly such as "E-Mail Address" instead
191+
| of "email". This simply helps us make our message more expressive.
145192
|
146193
*/
147194

src/PersianLangServiceProvider.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@ public function register()
2323
*/
2424
public function boot()
2525
{
26-
if (method_exists($this, 'publishes')) {
27-
// For Laravel 5.3+
28-
$this->publishes([
29-
__DIR__.'/../lang/fa' => base_path('resources/lang/fa'),
30-
], 'persian-lang');
31-
}else {
32-
// For Laravel 5.0-5.2
33-
$this->app['files']->copyDirectory(
34-
__DIR__.'/../lang/fa',
35-
base_path('resources/lang/fa')
36-
);
26+
// For Laravel 8 and below, use the resources/lang directory
27+
$path = resource_path('lang/fa');
28+
29+
// Laravel 9+ uses lang directory in base path
30+
if (version_compare(app()->version(), '9.0', '>=')) {
31+
$path = base_path('lang/fa');
3732
}
33+
34+
$this->publishes([
35+
__DIR__.'/../lang/fa' => $path,
36+
], 'persian-lang');
3837
}
3938
}

0 commit comments

Comments
 (0)