Skip to content

Commit 9130896

Browse files
committedJun 5, 2019
doc files updated
1 parent a2ecc7f commit 9130896

File tree

2 files changed

+84
-22
lines changed

2 files changed

+84
-22
lines changed
 

‎docs/index.md

+41-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Localization Helper
22

3+
Package for convenient work with Laravel's localization features and fast language files generation.
4+
35
## Installation
46

57
Via Composer
@@ -8,17 +10,18 @@ Via Composer
810
$ composer require awes-io/localization-helper
911
```
1012

11-
In Laravel 5.5, the service provider and facade will automatically get registered. For older versions of the framework, follow the steps below:
13+
In Laravel 5.5+, service provider and facade will be automatically registered. For older versions, follow the steps below:
14+
15+
Register service provider in `config/app.php`:
1216

13-
Register the service provider in config/app.php
1417
```php
1518
'providers' => [
1619
// [...]
1720
AwesIO\LocalizationHelper\LocalizationHelperServiceProvider::class,
1821
],
1922
```
2023

21-
You may also register the LaravelLocalization facade:
24+
You may also register `LaravelLocalization` facade:
2225

2326
```php
2427
'aliases' => [
@@ -31,7 +34,7 @@ You may also register the LaravelLocalization facade:
3134

3235
### Config Files
3336

34-
In order to edit the default configuration for this package you may execute:
37+
In order to edit default configuration you may execute:
3538

3639
```
3740
php artisan vendor:publish --provider="AwesIO\LocalizationHelper\LocalizationHelperServiceProvider"
@@ -41,23 +44,52 @@ After that, `config/localizationhelper.php` will be created.
4144

4245
## Usage
4346

44-
Package registers global helper function:
47+
Package registers global helper function `_p($file_key, $default, $placeholders)`:
48+
49+
```php
50+
_p('auth.login', 'Login'); // "Login"
51+
```
52+
53+
It will create new localization file `auth.php` (if it doesn't exist) and write second parameter as language string under `login` key:
4554

4655
```php
47-
_p('auth.login', 'Login');
56+
return [
57+
"login" => "Login"
58+
];
4859
```
4960

50-
Placeholders support:
61+
On second call with same file/key `_p('auth.login')`, localization string will be returned, file will remain untouched.
62+
63+
Placeholders are also supported:
5164

5265
```php
5366
_p(
5467
'mail.invitation',
5568
'You’re invited to join :company company workspace',
56-
['company' => $this->data['company']]
69+
['company' => 'Awesio']
5770
);
5871
```
5972

60-
If key is returned, it means that string already exists and you trying to add new one using it as array.
73+
If key is returned, it means that string already exists in localization file and you are trying to add new one using its value as an array.
74+
75+
```php
76+
// in localization file.php
77+
return [
78+
"test" => "Test string"
79+
];
80+
81+
_p('file.test.new', 'Test string'); // will return "file.test.new"
82+
83+
_p('file.test_2.new', 'Test string'); // will return "Test string"
84+
85+
// and modify localization file:
86+
return [
87+
"test" => "Test string",
88+
"test_2" => [
89+
"new" => "Test string"
90+
]
91+
];
92+
```
6193

6294
## Testing
6395

‎readme.md

+43-13
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
[![Coverage report](https://repo.pkgkit.com/4GBWO/awes-io/localization-helper/badges/master/coverage.svg)](https://www.awes.io/)
44
[![Build status](https://repo.pkgkit.com/4GBWO/awes-io/localization-helper/badges/master/build.svg)](https://www.awes.io/)
5-
[![Composer Ready](https://www.pkgkit.com/4GBWO/awes-io/auth/status.svg)](https://www.awes.io/)
6-
[![Downloads](https://www.pkgkit.com/4GBWO/awes-io/auth/downloads.svg)](https://www.awes.io/)
7-
[![Last version](https://www.pkgkit.com/4GBWO/awes-io/auth/version.svg)](https://www.awes.io/)
5+
[![Composer Ready](https://www.pkgkit.com/4GBWO/awes-io/localization-helper/status.svg)](https://www.awes.io/)
6+
[![Downloads](https://www.pkgkit.com/4GBWO/awes-io/localization-helper/downloads.svg)](https://www.awes.io/)
7+
[![Last version](https://www.pkgkit.com/4GBWO/awes-io/localization-helper/version.svg)](https://www.awes.io/)
88

9-
Package for convenient work with Laravel's localization features. Take a look at [contributing.md](contributing.md) to see a to do list.
9+
Package for convenient work with Laravel's localization features and fast language files generation. Take a look at [contributing.md](contributing.md) to see a to do list.
1010

1111
## Installation
1212

@@ -16,17 +16,18 @@ Via Composer
1616
$ composer require awes-io/localization-helper
1717
```
1818

19-
In Laravel 5.5, the service provider and facade will automatically get registered. For older versions of the framework, follow the steps below:
19+
In Laravel 5.5+, service provider and facade will be automatically registered. For older versions, follow the steps below:
20+
21+
Register service provider in `config/app.php`:
2022

21-
Register the service provider in config/app.php
2223
```php
2324
'providers' => [
2425
// [...]
2526
AwesIO\LocalizationHelper\LocalizationHelperServiceProvider::class,
2627
],
2728
```
2829

29-
You may also register the LaravelLocalization facade:
30+
You may also register `LaravelLocalization` facade:
3031

3132
```php
3233
'aliases' => [
@@ -39,7 +40,7 @@ You may also register the LaravelLocalization facade:
3940

4041
### Config Files
4142

42-
In order to edit the default configuration for this package you may execute:
43+
In order to edit default configuration you may execute:
4344

4445
```
4546
php artisan vendor:publish --provider="AwesIO\LocalizationHelper\LocalizationHelperServiceProvider"
@@ -49,23 +50,52 @@ After that, `config/localizationhelper.php` will be created.
4950

5051
## Usage
5152

52-
Package registers global helper function:
53+
Package registers global helper function `_p($file_key, $default, $placeholders)`:
5354

5455
```php
55-
_p('auth.login', 'Login');
56+
_p('auth.login', 'Login'); // "Login"
5657
```
5758

58-
Placeholders support:
59+
It will create new localization file `auth.php` (if it doesn't exist) and write second parameter as language string under `login` key:
60+
61+
```php
62+
return [
63+
"login" => "Login"
64+
];
65+
```
66+
67+
On second call with same file/key `_p('auth.login')`, localization string will be returned, file will remain untouched.
68+
69+
Placeholders are also supported:
5970

6071
```php
6172
_p(
6273
'mail.invitation',
6374
'You’re invited to join :company company workspace',
64-
['company' => $this->data['company']]
75+
['company' => 'Awesio']
6576
);
6677
```
6778

68-
If key is returned, it means that string already exists and you trying to add new one using it as array.
79+
If key is returned, it means that string already exists in localization file and you are trying to add new one using its value as an array.
80+
81+
```php
82+
// in localization file.php
83+
return [
84+
"test" => "Test string"
85+
];
86+
87+
_p('file.test.new', 'Test string'); // will return "file.test.new"
88+
89+
_p('file.test_2.new', 'Test string'); // will return "Test string"
90+
91+
// and modify localization file:
92+
return [
93+
"test" => "Test string",
94+
"test_2" => [
95+
"new" => "Test string"
96+
]
97+
];
98+
```
6999

70100
## Change log
71101

0 commit comments

Comments
 (0)
Please sign in to comment.