aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Parviainen <saparvia@caterva.eu>2014-12-30 20:34:26 +0100
committerStefan Parviainen <saparvia@caterva.eu>2014-12-30 20:34:26 +0100
commitb54bbf0fb8af72bd5273597f564f084aa1c1ac79 (patch)
treebdcf1f2a26dcbb29dff4c82839ccc676af5830c9
parent9cab8ae58a29ecf7387e6865aa170715caeabf04 (diff)
downloadvolse-hubzilla-b54bbf0fb8af72bd5273597f564f084aa1c1ac79.tar.gz
volse-hubzilla-b54bbf0fb8af72bd5273597f564f084aa1c1ac79.tar.bz2
volse-hubzilla-b54bbf0fb8af72bd5273597f564f084aa1c1ac79.zip
Update function doc, return language code if language is not recognized
-rw-r--r--include/language.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/include/language.php b/include/language.php
index 0db5ec86e..f5ee3471e 100644
--- a/include/language.php
+++ b/include/language.php
@@ -250,8 +250,7 @@ function detect_language($s) {
* By default we use the localized language name. You can switch the result
* to any language with the optional 2nd parameter $l.
*
- * $s and $l can be in any format that PHP's Locale understands. We will mostly
- * use the 2-letter ISO 639-1 (en, de, fr) format.
+ * $s and $l should be in 2-letter ISO 639-1 format
*
* If nothing could be looked up it returns $s.
*
@@ -275,7 +274,12 @@ function get_language_name($s, $l = null) {
catch(CommerceGuys\Intl\Exception\UnknownLanguageException $e) {
$s = substr($s,0,2);
if($l !== null) $l = substr($s,0,2);
- $language = $languageRepository->get($s, $l);
+ try {
+ $language = $languageRepository->get($s, $l);
+ }
+ catch(CommerceGuys\Intl\Exception\UnknownLanguageException $e) {
+ return $s; // Give up
+ }
}
return $language->getName();