@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | $file_path = $base_path.$this->multilingual_parameters['translations']; |
47 | 47 | $yaml = file_get_contents($file_path); |
48 | 48 | $yaml_parse_array_check = Yaml::parse($yaml); |
49 | - if(is_array($yaml_parse_array_check)) { |
|
49 | + if (is_array($yaml_parse_array_check)) { |
|
50 | 50 | $this->translations = $yaml_parse_array_check; |
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | 54 | public function initializeMultilanguage() { |
55 | - if(isset($this->multilingual_parameters['translations'])) { |
|
55 | + if (isset($this->multilingual_parameters['translations'])) { |
|
56 | 56 | $this->parseTranslationFile(); |
57 | 57 | } |
58 | 58 | $this->parseLanguageCodes(); |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | $current_url = $this->getSession()->getCurrentUrl(); |
77 | 77 | $base_url = $this->getMinkParameter('base_url'); |
78 | 78 | $base_url_length = strlen($base_url); |
79 | - $clean_url_language_code = substr($current_url,$base_url_length,2); |
|
80 | - $not_clean_url_language_code = substr($current_url,$base_url_length+3,2); |
|
79 | + $clean_url_language_code = substr($current_url, $base_url_length, 2); |
|
80 | + $not_clean_url_language_code = substr($current_url, $base_url_length + 3, 2); |
|
81 | 81 | |
82 | - if(in_array($clean_url_language_code,$this->languages_iso_codes)) { |
|
82 | + if (in_array($clean_url_language_code, $this->languages_iso_codes)) { |
|
83 | 83 | return $clean_url_language_code; |
84 | 84 | } |
85 | - else if (in_array($not_clean_url_language_code,$this->languages_iso_codes)){ |
|
85 | + else if (in_array($not_clean_url_language_code, $this->languages_iso_codes)) { |
|
86 | 86 | return $not_clean_url_language_code; |
87 | 87 | } |
88 | 88 | else return $this->multilingual_parameters['default_language']; |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | |
98 | 98 | public function localizeTarget($target) { |
99 | 99 | $translations = $this->multilingual_parameters['translations']; |
100 | - if(isset($this->translations[$target][$this->multilingual_parameters['default_language']])){ |
|
100 | + if (isset($this->translations[$target][$this->multilingual_parameters['default_language']])) { |
|
101 | 101 | $target = $this->translations[$target][$this->languageDetection()]; |
102 | 102 | return $target; |
103 | 103 | } |
104 | 104 | elseif (isset($this->translations[$target])) { |
105 | 105 | return $target; |
106 | 106 | } |
107 | - else throw new \Exception ("The text '$target'' is not defined in '$translations' translation file."); |
|
107 | + else throw new \Exception("The text '$target'' is not defined in '$translations' translation file."); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | public function localizeField($field) { |
115 | 115 | $re = "/(?:[-])(".$this->multilingual_parameters['default_language'].")(?:[-])/"; |
116 | 116 | $language = "-".$this->languageDetection()."-"; |
117 | - $field = preg_replace($re, $language,$field); |
|
117 | + $field = preg_replace($re, $language, $field); |
|
118 | 118 | return $field; |
119 | 119 | } |
120 | 120 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @When /^I wait for localized text "([^"]*)" to appear with max time "([^"]+)"(?: seconds)?$/ |
205 | 205 | */ |
206 | - public function iWaitForLocalizedTextToAppearWithMaxTime($target, $maxExecutionTime){ |
|
206 | + public function iWaitForLocalizedTextToAppearWithMaxTime($target, $maxExecutionTime) { |
|
207 | 207 | $target = $this->localizeTarget($target); |
208 | 208 | $this->iWaitForTextToAppearWithMaxTime($target, $maxExecutionTime); |
209 | 209 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @Given I click localized :link in the :rowText row |
228 | 228 | * @Then I (should )see the localized :link in the :rowText row |
229 | 229 | */ |
230 | - public function assertLocalizedClickInTableRow($link, $rowText){ |
|
230 | + public function assertLocalizedClickInTableRow($link, $rowText) { |
|
231 | 231 | $link = $this->localizeTarget($link); |
232 | 232 | $page = $this->getSession()->getPage(); |
233 | 233 | if ($link_element = $this->getTableRow($page, $rowText)->findLink($link)) { |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @When /^I click on the localized text "([^"]*)" in the "(?P<region>[^"]*)"(?:| region)$/ |
258 | 258 | */ |
259 | - public function iClickOnTheLocalizedTextInRegion($text, $region){ |
|
259 | + public function iClickOnTheLocalizedTextInRegion($text, $region) { |
|
260 | 260 | $text = $this->localizeTarget($text); |
261 | 261 | $this->iClickOnTheTextInRegion($text, $region); |
262 | 262 | } |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | |
82 | 82 | if(in_array($clean_url_language_code,$this->languages_iso_codes)) { |
83 | 83 | return $clean_url_language_code; |
84 | - } |
|
85 | - else if (in_array($not_clean_url_language_code,$this->languages_iso_codes)){ |
|
84 | + } else if (in_array($not_clean_url_language_code,$this->languages_iso_codes)){ |
|
86 | 85 | return $not_clean_url_language_code; |
86 | + } else { |
|
87 | + return $this->multilingual_parameters['default_language']; |
|
87 | 88 | } |
88 | - else return $this->multilingual_parameters['default_language']; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | if(isset($this->translations[$target][$this->multilingual_parameters['default_language']])){ |
101 | 101 | $target = $this->translations[$target][$this->languageDetection()]; |
102 | 102 | return $target; |
103 | - } |
|
104 | - elseif (isset($this->translations[$target])) { |
|
103 | + } elseif (isset($this->translations[$target])) { |
|
105 | 104 | return $target; |
105 | + } else { |
|
106 | + throw new \Exception ("The text '$target'' is not defined in '$translations' translation file."); |
|
106 | 107 | } |
107 | - else throw new \Exception ("The text '$target'' is not defined in '$translations' translation file."); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |