Skip to content

Commit 866334c

Browse files
committed
Update README.md
1 parent 9e85a09 commit 866334c

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

README.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,74 @@
1-
# laravel-language-center
1+
# Laravel Language Center
22
Language Center for Laravel.
3+
4+
# Install
5+
6+
Run `composer require novasa/laravel-language-center:~1.0`.
7+
8+
In `config/app.php` replace `Illuminate\Translation\TranslationServiceProvider::class,` with `Novasa\LaravelLanguageCenter\TranslationServiceProvider::class,` in the `providers`-section.
9+
10+
Then add the the following environments to your application:
11+
```
12+
LANGUAGE_CENTER_URL=The url for API v1 (with ending slash) (required)
13+
LANGUAGE_CENTER_USERNAME=Language Center username for Basic Auth (required)
14+
LANGUAGE_CENTER_PASSWORD=Language Center password for Basic Auth (required)
15+
LANGUAGE_CENTER_PLATFORM=The default platform to use. (default 'web')
16+
```
17+
18+
For publishing the configuration file run:
19+
```
20+
php artisan vendor:publish --provider="Novasa\LaravelLanguageCenter\TranslationServiceProvider" --tag="config"
21+
```
22+
23+
# Usage
24+
25+
You can use the Laravel standard `trans`-function.
26+
27+
```
28+
trans('header.login');
29+
```
30+
> will return the value of the string id `header.login`.
31+
> However if the string id for `header.login` does not exists it will return `header.login`.
32+
33+
```
34+
trans('header.welcome_back', [
35+
'username' => 'Mark',
36+
])
37+
```
38+
> Will return the value of the string id 'header.welcome_back', but will replace ':username' with 'Mark' in the translation.
39+
> However if the string id for `header.welcome_back` does not exists it will return `header.welcome_back`.
40+
41+
```
42+
trans([
43+
'key' => 'header.hello_world',
44+
'string' => 'Hello World!',
45+
])
46+
```
47+
> Will return the value of the string id 'header.hello_world'.
48+
> However if the string id for `header.hello_world` does not exists it will return `Hello World!`.
49+
50+
```
51+
trans([
52+
'key' => 'header.hello_user',
53+
'string' => 'Hello :username!',
54+
], [
55+
'username' => 'Mark',
56+
])
57+
```
58+
> Will return the value of the string id 'header.hello_user', but will replace ':username' with 'Mark' in the translation.
59+
> However if the string id for `header.hello_user` does not exists it will return `Hello Mark!`.
60+
61+
```
62+
trans([
63+
'key' => 'header.download',
64+
'string' => 'You should download our iOS app!',
65+
'platform' => 'ios',
66+
])
67+
```
68+
> Will return the value of the string id 'header.download', but for the platorm `ios`.
69+
> However if the string id for `header.download` does not exists it will return `You should download our iOS app!`.
70+
71+
#### Note
72+
If a translation does not exists it will automatically be created at the Language Center.
73+
74+
Also please note that the `locale` and `local_fallback` in the Laravel configurations are overwritten by the settings from the Language Center.

0 commit comments

Comments
 (0)