aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRedMatrix <info@friendica.com>2014-12-31 10:43:19 +1100
committerRedMatrix <info@friendica.com>2014-12-31 10:43:19 +1100
commit4f35efa0bad4ae6489b63f3eebafe6542d654094 (patch)
treefdf7577c0b602a1f8b86401572e53cfe90cf2474 /include
parentae9d08267c632cae36a4ebd34c2077fd0051e0e7 (diff)
downloadvolse-hubzilla-4f35efa0bad4ae6489b63f3eebafe6542d654094.tar.gz
volse-hubzilla-4f35efa0bad4ae6489b63f3eebafe6542d654094.tar.bz2
volse-hubzilla-4f35efa0bad4ae6489b63f3eebafe6542d654094.zip
Revert "Language names via intl library."
Diffstat (limited to 'include')
-rw-r--r--include/language.php30
-rw-r--r--include/text.php2
2 files changed, 7 insertions, 25 deletions
diff --git a/include/language.php b/include/language.php
index f5ee3471e..9db57dceb 100644
--- a/include/language.php
+++ b/include/language.php
@@ -250,7 +250,8 @@ 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 should be in 2-letter ISO 639-1 format
+ * $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.
*
* If nothing could be looked up it returns $s.
*
@@ -258,30 +259,11 @@ function detect_language($s) {
* @param $l (optional) In which language to return the name
* @return string with the language name, or $s if unrecognized
*/
-require_once(__DIR__ . '/../library/intl/vendor/autoload.php');
-use CommerceGuys\Intl\Language\LanguageRepository;
function get_language_name($s, $l = null) {
- // get() expects the second part to be in upper case
- if(strpos($s,'-') !== false) $s = substr($s,0,2) . strtoupper(substr($s,2));
- if($l !== null && strpos($l,'-') !== false) $l = substr($l,0,2) . strtoupper(substr($l,2));
+ if($l === null)
+ $l = $s;
- $languageRepository = new LanguageRepository;
-
- // Sometimes intl doesn't like the second part at all ...
- try {
- $language = $languageRepository->get($s, $l);
- }
- catch(CommerceGuys\Intl\Exception\UnknownLanguageException $e) {
- $s = substr($s,0,2);
- if($l !== null) $l = substr($s,0,2);
- try {
- $language = $languageRepository->get($s, $l);
- }
- catch(CommerceGuys\Intl\Exception\UnknownLanguageException $e) {
- return $s; // Give up
- }
- }
-
- return $language->getName();
+ logger('get_language_name: for ' . $s . ' in ' . $l . ' returns: ' . Locale::getDisplayLanguage($s, $l), LOGGER_DEBUG);
+ return Locale::getDisplayLanguage($s, $l);
}
diff --git a/include/text.php b/include/text.php
index ca9c51bc3..cd34fd88d 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1629,7 +1629,7 @@ function lang_selector() {
$ll = substr($l,5);
$ll = substr($ll,0,strrpos($ll,'/'));
$selected = (($ll === $a->language && (x($_SESSION, 'language'))) ? $ll : $selected);
- $lang_options[$ll] = get_language_name($ll, $ll) . " ($ll)";
+ $lang_options[$ll]=$ll;
}
}