PHP 클래스 Mcamara\LaravelLocalization\LaravelLocalization

파일 보기 프로젝트 열기: mcamara/laravel-localization 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$app Illuminate\Foundation\Application Illuminate request class.
$baseUrl string Illuminate request class.
$configRepository Illuminate\Config\Repository Config repository.
$currentLocale string Current locale
$defaultLocale string Default locale
$request Illuminate\Routing\Request Illuminate request class.
$routeName string Name of the translation key of the current route, it is used for url translations
$router Illuminate\Routing\Router Illuminate router class.
$supportedLocales array Supported Locales
$translatedRoutes array An array that contains all routes that should be translated
$translator Illuminate\Translation\Translator Illuminate translator class.
$view Illuminate\View\Factory Illuminate view Factory.

공개 메소드들

메소드 설명
__construct ( ) Creates new instance.
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 ( ) : Illuminate\Config\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)

보호된 메소드들

메소드 설명
checkUrl ( string $url ) : boolean Returns true if the string given is a valid url
extractAttributes ( boolean | false | null | string $url = false, string $locale = '' ) : array Extract attributes for current url
findTranslatedRouteByPath ( string $path, string $url_locale ) : string | false Returns the translated route for the path and the url given
findTranslatedRouteByUrl ( string | false | null $url, array $attributes, string $locale ) : string | false Returns the translated route for an url and the attributes given and a locale
getTranslatedRoutes ( ) : array Returns translated routes
substituteAttributesInRoute ( $attributes, string $route ) : string Change route attributes for the ones in the $attributes array
unparseUrl ( array | false $parsed_url ) : string Build URL using array data from parse_url
useAcceptLanguageHeader ( ) : boolean Returns the translation key for a given path

메소드 상세

__construct() 공개 메소드

Creates new instance.
public __construct ( )

checkLocaleInSupportedLocales() 공개 메소드

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

checkUrl() 보호된 메소드

Returns true if the string given is a valid url
protected checkUrl ( string $url ) : boolean
$url string String to check if it is a valid url
리턴 boolean Is the string given a valid url?

createUrlFromUri() 공개 메소드

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

extractAttributes() 보호된 메소드

Extract attributes for current url
protected extractAttributes ( boolean | false | null | string $url = false, string $locale = '' ) : array
$url boolean | false | null | string to extract attributes, if not present, the system will look for attributes in the current call
$locale string
리턴 array Array with attributes

findTranslatedRouteByPath() 보호된 메소드

Returns the translated route for the path and the url given
protected findTranslatedRouteByPath ( string $path, string $url_locale ) : string | false
$path string Path to check if it is a translated route
$url_locale string Language to check if the path exists
리턴 string | false Key for translation, false if not exist

findTranslatedRouteByUrl() 보호된 메소드

Returns the translated route for an url and the attributes given and a locale
protected findTranslatedRouteByUrl ( string | false | null $url, array $attributes, string $locale ) : string | false
$url string | false | null Url to check if it is a translated route
$attributes array Attributes to check if the url exists in the translated routes array
$locale string Language to check if the url exists
리턴 string | false Key for translation, false if not exist

getConfigRepository() 공개 메소드

Returns the config repository for this instance
public getConfigRepository ( ) : Illuminate\Config\Repository
리턴 Illuminate\Config\Repository Configuration repository

getCurrentLocale() 공개 메소드

Returns current language
public getCurrentLocale ( ) : string
리턴 string current language

getCurrentLocaleDirection() 공개 메소드

Returns current locale direction
public getCurrentLocaleDirection ( ) : string
리턴 string current locale direction

getCurrentLocaleName() 공개 메소드

Returns current locale name
public getCurrentLocaleName ( ) : string
리턴 string current locale name

getCurrentLocaleNative() 공개 메소드

Returns current locale native name
public getCurrentLocaleNative ( ) : string
리턴 string current locale native name

getCurrentLocaleNativeReading() 공개 메소드

Returns current language's native reading
public getCurrentLocaleNativeReading ( ) : string
리턴 string current language's native reading

getCurrentLocaleRegional() 공개 메소드

Returns current regional
public getCurrentLocaleRegional ( ) : string
리턴 string current regional

getCurrentLocaleScript() 공개 메소드

Returns current locale script
public getCurrentLocaleScript ( ) : string
리턴 string current locale script

getDefaultLocale() 공개 메소드

Returns default locale
public getDefaultLocale ( ) : string
리턴 string

getLocalizedURL() 공개 메소드

Returns an URL adapted to $locale
public 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 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 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 getSupportedLanguagesKeys ( ) : array
리턴 array keys of supported languages

getSupportedLocales() 공개 메소드

Return an array of all supported Locales
public getSupportedLocales ( ) : array
리턴 array

getTranslatedRoutes() 보호된 메소드

Returns translated routes
protected getTranslatedRoutes ( ) : array
리턴 array translated routes

getURLFromRouteNameTranslated() 공개 메소드

Returns an URL adapted to the route name and the locale given
public 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 hideDefaultLocaleInURL ( ) : boolean
리턴 boolean Returns value of hideDefaultLocaleInURL in config.

localizeURL() 공개 메소드

Returns an URL adapted to $locale or current locale
public 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 setBaseUrl ( string $url )
$url string Base url for the site

setLocale() 공개 메소드

Set and return current locale
public 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 setRouteName ( string $routeName )
$routeName string current route name

setSupportedLocales() 공개 메소드

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

substituteAttributesInRoute() 보호된 메소드

Change route attributes for the ones in the $attributes array
protected substituteAttributesInRoute ( $attributes, string $route ) : string
$attributes array Array of attributes
$route string string route to substitute
리턴 string route with attributes changed

transRoute() 공개 메소드

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

unparseUrl() 보호된 메소드

Build URL using array data from parse_url
protected unparseUrl ( array | false $parsed_url ) : string
$parsed_url array | false Array of data from parse_url function
리턴 string Returns URL as string.

useAcceptLanguageHeader() 보호된 메소드

Returns the translation key for a given path
protected useAcceptLanguageHeader ( ) : boolean
리턴 boolean Returns value of useAcceptLanguageHeader in config.

프로퍼티 상세

$app 보호되어 있는 프로퍼티

Illuminate request class.
protected Application,Illuminate\Foundation $app
리턴 Illuminate\Foundation\Application

$baseUrl 보호되어 있는 프로퍼티

Illuminate request class.
protected string $baseUrl
리턴 string

$configRepository 보호되어 있는 프로퍼티

Config repository.
protected Repository,Illuminate\Config $configRepository
리턴 Illuminate\Config\Repository

$currentLocale 보호되어 있는 프로퍼티

Current locale
protected string $currentLocale
리턴 string

$defaultLocale 보호되어 있는 프로퍼티

Default locale
protected string $defaultLocale
리턴 string

$request 보호되어 있는 프로퍼티

Illuminate request class.
protected Request,Illuminate\Routing $request
리턴 Illuminate\Routing\Request

$routeName 보호되어 있는 프로퍼티

Name of the translation key of the current route, it is used for url translations
protected string $routeName
리턴 string

$router 보호되어 있는 프로퍼티

Illuminate router class.
protected Router,Illuminate\Routing $router
리턴 Illuminate\Routing\Router

$supportedLocales 보호되어 있는 프로퍼티

Supported Locales
protected array $supportedLocales
리턴 array

$translatedRoutes 보호되어 있는 프로퍼티

An array that contains all routes that should be translated
protected array $translatedRoutes
리턴 array

$translator 보호되어 있는 프로퍼티

Illuminate translator class.
protected Translator,Illuminate\Translation $translator
리턴 Illuminate\Translation\Translator

$view 보호되어 있는 프로퍼티

Illuminate view Factory.
protected Factory,Illuminate\View $view
리턴 Illuminate\View\Factory