PHP Class Arcanedev\Localization\Utilities\RouteTranslator

Author: ARCANEDEV ([email protected])
Inheritance: implements Arcanedev\Localization\Contracts\RouteTranslatorInterface
Datei anzeigen Open project: arcanedev/localization

Protected Properties

Property Type Description
$currentRoute string Current route.
$translatedRoutes array Translated routes collection.

Public Methods

Method Description
__construct ( Illuminate\Translation\Translator $translator ) Create RouteTranslator instance.
findTranslatedRouteByPath ( string $path, string $locale ) : false | string Returns the translated route for the path and the url given.
getCurrentRoute ( ) : string Get current route.
getRouteNameFromPath ( string $uri, string $locale ) : false | string Returns the translation key for a given path.
getTranslatedRoute ( string $baseUrl, array | false &$parsedUrl, string $defaultLocale, Arcanedev\Localization\Entities\LocaleCollection $supportedLocales ) : string | false Get the translated route.
getTranslatedRoutes ( ) : array Get translated routes.
getUrlFromRouteName ( string $locale, string $defaultLocale, string $transKey, array $attributes = [], boolean | false $defaultHidden = false ) : string Get URL from route name.
hasCurrentRoute ( ) : boolean Check if has current route.
hasTranslation ( string $key, string $locale = null ) : boolean Determine if a translation exists.
setCurrentRoute ( false | string $currentRoute ) : self Set the current route.
trans ( string $route, string | null $locale = null ) : string Translate routes and save them to the translated routes array (used in the localize route filter).

Private Methods

Method Description
translate ( string $key, string $locale = null ) : string Get the translation for a given key.

Method Details

__construct() public method

Create RouteTranslator instance.
public __construct ( Illuminate\Translation\Translator $translator )
$translator Illuminate\Translation\Translator

findTranslatedRouteByPath() public method

Returns the translated route for the path and the url given.
public findTranslatedRouteByPath ( string $path, string $locale ) : false | string
$path string - Path to check if it is a translated route
$locale string - Language to check if the path exists
return false | string

getCurrentRoute() public method

Get current route.
public getCurrentRoute ( ) : string
return string

getRouteNameFromPath() public method

Returns the translation key for a given path.
public getRouteNameFromPath ( string $uri, string $locale ) : false | string
$uri string
$locale string
return false | string

getTranslatedRoute() public method

Get the translated route.
public getTranslatedRoute ( string $baseUrl, array | false &$parsedUrl, string $defaultLocale, Arcanedev\Localization\Entities\LocaleCollection $supportedLocales ) : string | false
$baseUrl string
$parsedUrl array | false
$defaultLocale string
$supportedLocales Arcanedev\Localization\Entities\LocaleCollection
return string | false

getTranslatedRoutes() public method

Get translated routes.
public getTranslatedRoutes ( ) : array
return array

getUrlFromRouteName() public method

Get URL from route name.
public getUrlFromRouteName ( string $locale, string $defaultLocale, string $transKey, array $attributes = [], boolean | false $defaultHidden = false ) : string
$locale string
$defaultLocale string
$transKey string
$attributes array
$defaultHidden boolean | false
return string

hasCurrentRoute() public method

Check if has current route.
public hasCurrentRoute ( ) : boolean
return boolean

hasTranslation() public method

Determine if a translation exists.
public hasTranslation ( string $key, string $locale = null ) : boolean
$key string
$locale string
return boolean

setCurrentRoute() public method

Set the current route.
public setCurrentRoute ( false | string $currentRoute ) : self
$currentRoute false | string
return self

trans() public method

Translate routes and save them to the translated routes array (used in the localize route filter).
public trans ( string $route, string | null $locale = null ) : string
$route string
$locale string | null
return string

Property Details

$currentRoute protected_oe property

Current route.
protected string $currentRoute
return string

$translatedRoutes protected_oe property

Translated routes collection.
protected array $translatedRoutes
return array