forked from mage-websd/extensiongsd
/
Language.php
78 lines (68 loc) · 1.9 KB
/
Language.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* You are allowed to use this API in your web application.
*
* Copyright (C) 2015 by customweb GmbH
*
* This program is licenced under the customweb software licence. With the
* purchase or the installation of the software in your application you
* accept the licence agreement. The allowed usage is outlined in the
* customweb software licence which can be found under
* http://www.sellxed.com/en/software-license-agreement
*
* Any modification or distribution is strictly forbidden. The license
* grants you the installation in one application. For multiuse you will need
* to purchase further licences at http://www.sellxed.com/shop.
*
* See the customweb software licence agreement for more details.
*
*/
//require_once 'Customweb/Core/Util/Language.php';
//require_once 'Customweb/Core/Assert.php';
/**
* Basic language object
*
* @author Thomas Hunziker / Nico Eigenmann
*
*/
class Customweb_Core_Language {
private $ietfCode;
private $language = null;
/**
* Accepts any language input (IETF code, ISO Code or any other language name)
*
* @param string $language
* @throws Exception
*/
public function __construct($language) {
$language = (string)$language;
Customweb_Core_Assert::hasLength($language, "The given language is empty.");
$this->language = $language;
}
/**
* @return string
*/
public function getIetfCode() {
return Customweb_Core_Util_Language::getIetfCode($this->language);
}
/**
* @return string
*/
public function getIso2LetterCode() {
return Customweb_Core_Util_Language::getLanguageFromIETF(Customweb_Core_Util_Language::getIetfCode($this->language));
}
/**
* @return string
*/
public function __toString() {
return $this->language;
}
/**
* This method returns the not normalized language code / name input.
*
* @return string
*/
public function getOriginalLanguageInput() {
return $this->language;
}
}