PHP Class Neos\Flow\I18n\Utility

Afficher le fichier Open project: neos/flow-development-collection Class Usage Examples

Méthodes publiques

Méthode Description
extractLocaleTagFromFilename ( string $filename ) : mixed Extracts a locale tag (identifier) from the filename given.
parseAcceptLanguageHeader ( string $acceptLanguageHeader ) : mixed Parses Accept-Language header and returns array of locale tags (like: en-GB, en), or FALSE if no tags were found.
stringBeginsWith ( string $haystack, string $needle ) : boolean Checks if $haystack string begins with $needle string.
stringEndsWith ( string $haystack, string $needle ) : boolean Checks if $haystack string ends with $needle string.

Method Details

extractLocaleTagFromFilename() public static méthode

Locale tag should be placed just before the extension of the file. For example, filename bar.png can be localized as bar.en_GB.png, and this method extracts en_GB from the name. Note: this ignores matches on rss, xml and php and validates the identifier.
public static extractLocaleTagFromFilename ( string $filename ) : mixed
$filename string Filename to extract locale identifier from
Résultat mixed The string with extracted locale identifier of FALSE on failure

parseAcceptLanguageHeader() public static méthode

This method only returns tags that conforms ISO 639 for language codes and ISO 3166 for region codes. HTTP spec (RFC 2616) defines both of these parts as 1*8ALPHA, but this method ignores tags with longer (or shorter) codes than defined in ISO mentioned above. There can be an asterisk "*" in the returned array, which means that any language is acceptable. Warning: This method expects that locale tags are placed in descending order by quality in the $header string. I'm not sure if it's always true with the web browsers.
public static parseAcceptLanguageHeader ( string $acceptLanguageHeader ) : mixed
$acceptLanguageHeader string
Résultat mixed The array of locale identifiers or FALSE

stringBeginsWith() public static méthode

Checks if $haystack string begins with $needle string.
public static stringBeginsWith ( string $haystack, string $needle ) : boolean
$haystack string
$needle string
Résultat boolean TRUE if $haystack begins with $needle

stringEndsWith() public static méthode

Checks if $haystack string ends with $needle string.
public static stringEndsWith ( string $haystack, string $needle ) : boolean
$haystack string
$needle string
Résultat boolean TRUE if $haystack ends with $needle