Elgg
Version 5.1
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
engine
classes
Elgg
I18n
Locale.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Elgg\I18n
;
4
5
use
Elgg\Exceptions\I18n\InvalidLocaleException
;
6
13
final
class
Locale
{
14
16
private
$locale;
17
23
private
function
__construct($locale) {
24
$this->locale = $locale;
25
}
26
30
public
function
__toString
() {
31
return
$this->locale;
32
}
33
43
public
static
function
parse
($locale) {
44
if
(!
preg_match
(
'~^[a-z0-9_]{2,20}$~'
, $locale)) {
45
throw
new
InvalidLocaleException
(
"Unrecognized locale: $locale"
);
46
}
47
48
return
new
Locale
($locale);
49
}
50
}
Elgg\I18n\Locale\parse
static parse($locale)
Create a language, asserting that the language code is valid.
Definition:
Locale.php:43
Elgg\Exceptions\I18n\InvalidLocaleException
Indicated an invalid Locale was given.
Definition:
InvalidLocaleException.php:12
Elgg\I18n\Locale\__toString
__toString()
Definition:
Locale.php:30
Elgg\I18n\Locale
Language class to ensure only valid languages are used.
Definition:
Locale.php:13
InvalidLocaleException
Elgg\I18n
Definition:
DateTime.php:3
preg_match
Generated on Wed Dec 6 2023 00:00:19 for Elgg by
1.8.11