PHP Класс LaravelLocalization, someline-starter

Наследование: extends Mcamara\LaravelLocalization\Facades\LaravelLocalization
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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)

Описание методов

checkLocaleInSupportedLocales() публичный статический Метод

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
Результат boolean is the locale supported?

createUrlFromUri() публичный статический Метод

Create an url from the uri
public static createUrlFromUri ( string $uri ) : string
$uri string Uri
Результат string Url for the given uri

getConfigRepository() публичный статический Метод

Returns the config repository for this instance
public static getConfigRepository ( ) : Mcamara\LaravelLocalization\Repository
Результат Mcamara\LaravelLocalization\Repository Configuration repository

getCurrentLocale() публичный статический Метод

Returns current language
public static getCurrentLocale ( ) : string
Результат string current language

getCurrentLocaleDirection() публичный статический Метод

Returns current locale direction
public static getCurrentLocaleDirection ( ) : string
Результат string current locale direction

getCurrentLocaleName() публичный статический Метод

Returns current locale name
public static getCurrentLocaleName ( ) : string
Результат string current locale name

getCurrentLocaleNative() публичный статический Метод

Returns current locale native name
public static getCurrentLocaleNative ( ) : string
Результат string current locale native name

getCurrentLocaleNativeReading() публичный статический Метод

Returns current language's native reading
public static getCurrentLocaleNativeReading ( ) : string
Результат string current language's native reading

getCurrentLocaleRegional() публичный статический Метод

Returns current regional
public static getCurrentLocaleRegional ( ) : string
Результат string current regional

getCurrentLocaleScript() публичный статический Метод

Returns current locale script
public static getCurrentLocaleScript ( ) : string
Результат string current locale script

getDefaultLocale() публичный статический Метод

Returns default locale
public static getDefaultLocale ( ) : string
Результат string

getLocalizedURL() публичный статический Метод

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.
Результат string | false URL translated, False if url does not exist

getNonLocalizedURL() публичный статический Метод

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
Результат string URL with no locale in path

getRouteNameFromAPath() публичный статический Метод

Returns the translation key for a given path
public static getRouteNameFromAPath ( string $path ) : string | false
$path string Path to get the key translated
Результат string | false Key for translation, false if not exist

getSupportedLanguagesKeys() публичный статический Метод

Returns supported languages language key
public static getSupportedLanguagesKeys ( ) : array
Результат array keys of supported languages

getSupportedLocales() публичный статический Метод

Return an array of all supported Locales
public static getSupportedLocales ( ) : array
Результат array

getURLFromRouteNameTranslated() публичный статический Метод

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)
Результат string | false URL translated

hideDefaultLocaleInURL() публичный статический Метод

Returns the translation key for a given path
public static hideDefaultLocaleInURL ( ) : boolean
Результат boolean Returns value of hideDefaultLocaleInURL in config.

localizeURL() публичный статический Метод

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
Результат string URL translated

setBaseUrl() публичный статический Метод

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

setLocale() публичный статический Метод

Set and return current locale
public static setLocale ( string $locale = null ) : string
$locale string Locale to set the App to (optional)
Результат string Returns locale (if route has any) or null (if route does not have a locale)

setRouteName() публичный статический Метод

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

setSupportedLocales() публичный статический Метод

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

transRoute() публичный статический Метод

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
Результат string Translated string