PHP Class LaravelLocalization, someline-starter

Inheritance: extends Mcamara\LaravelLocalization\Facades\LaravelLocalization
Mostrar archivo Open project: someline/someline-starter Class Usage Examples

Public Methods

Method Description
checkLocaleInSupportedLocales ( string | boolean $locale ) : boolean Check if Locale exists on the supported locales array
createUrlFromUri ( string $uri ) : string Create an url from the uri
getConfigRepository ( ) : Mcamara\LaravelLocalization\Repository Returns the config repository for this instance
getCurrentLocale ( ) : string Returns current language
getCurrentLocaleDirection ( ) : string Returns current locale direction
getCurrentLocaleName ( ) : string Returns current locale name
getCurrentLocaleNative ( ) : string Returns current locale native name
getCurrentLocaleNativeReading ( ) : string Returns current language's native reading
getCurrentLocaleRegional ( ) : string Returns current regional
getCurrentLocaleScript ( ) : string Returns current locale script
getDefaultLocale ( ) : string Returns default locale
getLocalizedURL ( string | boolean $locale = null, string | false $url = null, array $attributes = [] ) : string | false Returns an URL adapted to $locale
getNonLocalizedURL ( string | false $url = null ) : string It returns an URL without locale (if it has it) Convenience function wrapping getLocalizedURL(false)
getRouteNameFromAPath ( string $path ) : string | false Returns the translation key for a given path
getSupportedLanguagesKeys ( ) : array Returns supported languages language key
getSupportedLocales ( ) : array Return an array of all supported Locales
getURLFromRouteNameTranslated ( string | boolean $locale, string $transKeyName, array $attributes = [] ) : string | false Returns an URL adapted to the route name and the locale given
hideDefaultLocaleInURL ( ) : boolean Returns the translation key for a given path
localizeURL ( string $url = null, string | boolean $locale = null ) : string Returns an URL adapted to $locale or current locale
setBaseUrl ( string $url ) Sets the base url for the site
setLocale ( string $locale = null ) : string Set and return current locale
setRouteName ( string $routeName ) Set current route name
setSupportedLocales ( array $locales ) Set and return supported locales
transRoute ( string $routeName ) : string Translate routes and save them to the translated routes array (used in the localize route filter)

Method Details

checkLocaleInSupportedLocales() public static method

Check if Locale exists on the supported locales array
public static checkLocaleInSupportedLocales ( string | boolean $locale ) : boolean
$locale string | boolean string|bool Locale to be checked
return boolean is the locale supported?

createUrlFromUri() public static method

Create an url from the uri
public static createUrlFromUri ( string $uri ) : string
$uri string Uri
return string Url for the given uri

getConfigRepository() public static method

Returns the config repository for this instance
public static getConfigRepository ( ) : Mcamara\LaravelLocalization\Repository
return Mcamara\LaravelLocalization\Repository Configuration repository

getCurrentLocale() public static method

Returns current language
public static getCurrentLocale ( ) : string
return string current language

getCurrentLocaleDirection() public static method

Returns current locale direction
public static getCurrentLocaleDirection ( ) : string
return string current locale direction

getCurrentLocaleName() public static method

Returns current locale name
public static getCurrentLocaleName ( ) : string
return string current locale name

getCurrentLocaleNative() public static method

Returns current locale native name
public static getCurrentLocaleNative ( ) : string
return string current locale native name

getCurrentLocaleNativeReading() public static method

Returns current language's native reading
public static getCurrentLocaleNativeReading ( ) : string
return string current language's native reading

getCurrentLocaleRegional() public static method

Returns current regional
public static getCurrentLocaleRegional ( ) : string
return string current regional

getCurrentLocaleScript() public static method

Returns current locale script
public static getCurrentLocaleScript ( ) : string
return string current locale script

getDefaultLocale() public static method

Returns default locale
public static getDefaultLocale ( ) : string
return string

getLocalizedURL() public static method

Returns an URL adapted to $locale
public static getLocalizedURL ( string | boolean $locale = null, string | false $url = null, array $attributes = [] ) : string | false
$locale string | boolean Locale to adapt, false to remove locale
$url string | false URL to adapt in the current language. If not passed, the current url would be taken.
$attributes array Attributes to add to the route, if empty, the system would try to extract them from the url.
return string | false URL translated, False if url does not exist

getNonLocalizedURL() public static method

It returns an URL without locale (if it has it) Convenience function wrapping getLocalizedURL(false)
public static getNonLocalizedURL ( string | false $url = null ) : string
$url string | false URL to clean, if false, current url would be taken
return string URL with no locale in path

getRouteNameFromAPath() public static method

Returns the translation key for a given path
public static getRouteNameFromAPath ( string $path ) : string | false
$path string Path to get the key translated
return string | false Key for translation, false if not exist

getSupportedLanguagesKeys() public static method

Returns supported languages language key
public static getSupportedLanguagesKeys ( ) : array
return array keys of supported languages

getSupportedLocales() public static method

Return an array of all supported Locales
public static getSupportedLocales ( ) : array
return array

getURLFromRouteNameTranslated() public static method

Returns an URL adapted to the route name and the locale given
public static getURLFromRouteNameTranslated ( string | boolean $locale, string $transKeyName, array $attributes = [] ) : string | false
$locale string | boolean Locale to adapt
$transKeyName string Translation key name of the url to adapt
$attributes array Attributes for the route (only needed if transKeyName needs them)
return string | false URL translated

hideDefaultLocaleInURL() public static method

Returns the translation key for a given path
public static hideDefaultLocaleInURL ( ) : boolean
return boolean Returns value of hideDefaultLocaleInURL in config.

localizeURL() public static method

Returns an URL adapted to $locale or current locale
public static localizeURL ( string $url = null, string | boolean $locale = null ) : string
$url string URL to adapt. If not passed, the current url would be taken.
$locale string | boolean Locale to adapt, false to remove locale
return string URL translated

setBaseUrl() public static method

Sets the base url for the site
public static setBaseUrl ( string $url )
$url string Base url for the site

setLocale() public static method

Set and return current locale
public static setLocale ( string $locale = null ) : string
$locale string Locale to set the App to (optional)
return string Returns locale (if route has any) or null (if route does not have a locale)

setRouteName() public static method

Set current route name
public static setRouteName ( string $routeName )
$routeName string current route name

setSupportedLocales() public static method

Set and return supported locales
public static setSupportedLocales ( array $locales )
$locales array Locales that the App supports

transRoute() public static method

Translate routes and save them to the translated routes array (used in the localize route filter)
public static transRoute ( string $routeName ) : string
$routeName string Key of the translated string
return string Translated string