Skip to content

Commit

Permalink
Added information on setting up JSON Fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-helldar committed Nov 28, 2023
1 parent f0a95e3 commit d2b84e1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
51 changes: 51 additions & 0 deletions docs/topics/installation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Installation

## Common Package

You can install the package via [Composer](https://getcomposer.org):

```Bash
Expand Down Expand Up @@ -41,3 +43,52 @@ run the following console commands:
%install-common%
%install-locales%
```

## JSON Fallback

<include from="snippets-library.topic" element-id="json-fallback-doesnt-need"/>

<include from="snippets-library.topic" element-id="json-fallback-doesnt-allow"/>

To install, run the console command:

```Bash
%install-json-fallback-hotfix%
```

After this, you need to add a link to the service provider in the `providers` section of the `config/app.php`
settings file:

<tabs>
<tab title="Laravel 10+">
<code-block lang="php">
use Illuminate\Support\ServiceProvider;
<br/>
return [
'providers' => ServiceProvider::defaultProviders()->merge([
LaravelLang\JsonFallbackHotfix\TranslationServiceProvider::class,
<br/>
// ...
])
->replace([
Illuminate\Translation\TranslationServiceProvider::class => LaravelLang\JsonFallbackHotfix\TranslationServiceProvider::class,
])
->toArray()
];
</code-block>
</tab>
<tab title="Laravel 6-9">
<code-block lang="php">
return [
'providers' => [
// Illuminate\Translation\TranslationServiceProvider::class, &laquo; disabled this one<br/>
LaravelLang\JsonFallbackHotfix\TranslationServiceProvider::class,
<br/>
// ...
]
];
</code-block>
</tab>
</tabs>

Now JSON keys will correctly output the value based on the selected localization.
8 changes: 3 additions & 5 deletions docs/topics/packages-json-fallback.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ This package solves the problem of using JSON translations in applications where

This package solves this problem.

To install, run the console command:

```Bash
%install-json-fallback-hotfix%
```
> Read more about installation and configuration
> [**here**](installation.md#json-fallback)
> .
6 changes: 6 additions & 0 deletions docs/topics/snippets-library.topic
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<code>Se souvenir de moi</code> for French fallback language.
</snippet>

<snippet id="json-fallback-doesnt-need">
<warning>
If you use English as a fallback localization, then you do not need to install this package.
</warning>
</snippet>

<snippet id="lists-laravel-projects-inline">
<a href="https://laravel.com">Laravel Framework</a>,
<a href="https://jetstream.laravel.com/">Jetstream</a>,
Expand Down

0 comments on commit d2b84e1

Please sign in to comment.