aboutsummaryrefslogtreecommitdiffstats
path: root/langs.inc.php
diff options
context:
space:
mode:
authorFilip Komar <filip@mageia.org>2014-02-01 15:24:23 +0000
committerFilip Komar <filip@mageia.org>2014-02-01 15:24:23 +0000
commitbad35065a7db4589b08ed2f3b3fa109e552fb0d7 (patch)
tree63edf84308401f0e0e812dd2d574bf0e7f73d3e3 /langs.inc.php
parent3ad03d2182d5cc4e5a3d4ea63a98ea138771d886 (diff)
downloadwww-bad35065a7db4589b08ed2f3b3fa109e552fb0d7.tar
www-bad35065a7db4589b08ed2f3b3fa109e552fb0d7.tar.gz
www-bad35065a7db4589b08ed2f3b3fa109e552fb0d7.tar.bz2
www-bad35065a7db4589b08ed2f3b3fa109e552fb0d7.tar.xz
www-bad35065a7db4589b08ed2f3b3fa109e552fb0d7.zip
create function locale_hyphen_underscore and make use of it
Diffstat (limited to 'langs.inc.php')
-rw-r--r--langs.inc.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/langs.inc.php b/langs.inc.php
index c779efd9d..7180c9a1e 100644
--- a/langs.inc.php
+++ b/langs.inc.php
@@ -119,6 +119,28 @@ function relocate($langs, $page = '', $default_locale = 'en', $force_accept_lang
return $relocate;
}
+
+/**
+ * Create string pt_br from string pt-br and alike but leave the rest as is
+ * Return string.
+ * Do not exit the process.
+ *
+ * @param string $locale which we want to change
+ * @param boolean $version_of_locale_uppercase optional, true if we want second part in uppercase (pt_BR)
+ *
+ * @return string
+*/
+function locale_hyphen_underscore($locale, $version_of_locale_uppercase = false)
+{
+ preg_match("/(..)(-)(..)/", $locale, $parsed_locale);
+ if(isset($parsed_locale[3])) {
+ return $parsed_locale[1] . '_' . ($version_of_locale_uppercase ? strtoupper($parsed_locale[3]) : $parsed_locale[3]);
+ } else {
+ return $locale;
+ }
+}
+
+
/**
*/
function show_langs($langs)