Skip to content

Commit

Permalink
Added information about the new functionality of the Routes package
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-helldar committed Jul 7, 2024
1 parent ea106a3 commit a4eaee2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
15 changes: 15 additions & 0 deletions docs/snippets/packages-routes-auto-locale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

route('localized.show', ['bar' => 'show', 'locale' => app()->getLocale()]);
// https://example.com/fr/foo/show

route('localized.show', ['bar' => 'show', 'locale' => 'de']);
// https://example.com/de/foo/show

route('localized.show', ['bar' => 'show']);
// https://example.com/fr/foo/show

route('localized.show', ['bar' => 'show', 'locale' => 'de']);
// https://example.com/de/foo/show
20 changes: 19 additions & 1 deletion docs/topics/packages-routes.topic
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<chapter title="Usage" id="usage">
<link-summary>Usage information for the %repository-title-routes% package</link-summary>

<include from="library-models.topic" element-id="video-usage"/>
<include from="library-models.topic" element-id="video-usage" />

<p>
Let's say an application has two localizations installed - French and German.
Expand Down Expand Up @@ -530,6 +530,24 @@
of the <code>%config-filename%</code> file.
</p>

<note>
<p>
Since version <a href="https://github.com/Laravel-Lang/routes/releases/tag/1.4.0">1.4</a>,
when calling a localized route name, such as
<code>route('localized.show', ['bar' => 'show'])</code>,
there is no need to specify the current localization code.
</p>

<tabs>
<tab title="After">
<code-block lang="php" src="packages-routes-auto-locale.php" include-lines="11-15" />
</tab>
<tab title="Before">
<code-block lang="php" src="packages-routes-auto-locale.php" include-lines="5-9" />
</tab>
</tabs>
</note>

<chapter title="Examples" id="via_localization_group_examples">
<tabs>
<tab title="Default locale">
Expand Down

0 comments on commit a4eaee2

Please sign in to comment.