Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added information about the new functionality of the Routes package #41

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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