aboutsummaryrefslogtreecommitdiffstats
path: root/langs.inc.php
diff options
context:
space:
mode:
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)