-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from sl0wik/feature/language_helpers
Language helpers
- Loading branch information
Showing
10 changed files
with
71 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ class Website extends Model | |
use SoftDeletes; | ||
|
||
/** | ||
* Json objects | ||
* Json objects. | ||
* | ||
* @var array | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,4 @@ protected function setupConfig() | |
{ | ||
// @TODO | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/** | ||
* Returning translated (lozalized) url. | ||
* | ||
* @param string $url url for example /guides/{name} | ||
* @param string|null $attributes For example ['name' => 'Brazil'] | ||
* | ||
* @return string Localized url for example /guias/Brazil | ||
*/ | ||
function localize_url($url, $attributes = null) | ||
{ | ||
$prefix = request()->route()->getPrefix(); | ||
if (is_null($prefix)) { | ||
$url = \LaravelLocalization::getLocalizedURL( | ||
false, | ||
$url, | ||
$attributes | ||
); | ||
// LaravelLocalization seems to add locale even when its set to false | ||
$url = str_replace(LaravelLocalization::getCurrentLocale().'/', '', $url); | ||
|
||
return $url; | ||
} else { | ||
return \LaravelLocalization::getLocalizedURL( | ||
LaravelLocalization::getCurrentLocale(), | ||
$url, | ||
$attributes | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* Return current language code (locale). | ||
* Based on mcamara/laravel-localization function LaravelLocalization::getCurrentLocale(). | ||
* | ||
* @return string | ||
*/ | ||
function getCurrentLanguageCode() | ||
{ | ||
return LaravelLocalization::getCurrentLocale(); | ||
} |