From 994cc1dbb2051eba8dc346295803a677471b97fd Mon Sep 17 00:00:00 2001 From: spekary Date: Thu, 6 Jul 2017 13:59:52 -0700 Subject: [PATCH] Adding getLocale --- src/GettextTranslator.php | 10 ++++++++++ src/SimpleCacheTranslator.php | 10 ++++++++++ src/TranslatorInterface.php | 7 +++++++ 3 files changed, 27 insertions(+) diff --git a/src/GettextTranslator.php b/src/GettextTranslator.php index 6a3dc4a..3f8a3aa 100644 --- a/src/GettextTranslator.php +++ b/src/GettextTranslator.php @@ -173,4 +173,14 @@ public function setLanguage ($strLanguage, $strCountry = null) putenv("LANG=" . $locale); //ight need LANGUAGE setting too. setlocale(LC_ALL, $locale); } + + /** + * Return the current locale setting. + * + * @return string + */ + public function getLocale() + { + return setlocale(LC_ALL, 0); + } } \ No newline at end of file diff --git a/src/SimpleCacheTranslator.php b/src/SimpleCacheTranslator.php index 345d5ff..92f286a 100644 --- a/src/SimpleCacheTranslator.php +++ b/src/SimpleCacheTranslator.php @@ -202,6 +202,16 @@ public function setLanguage($strLanguage, $strCountry = null) } } + /** + * Returns the current locale as a string. + * + * @return string + */ + public function getLocale() + { + return $this->strLocale; + } + /** * Translate the given message. * diff --git a/src/TranslatorInterface.php b/src/TranslatorInterface.php index 204c8f0..3dfe8b8 100644 --- a/src/TranslatorInterface.php +++ b/src/TranslatorInterface.php @@ -70,6 +70,13 @@ public function translatePlural($strMsgId, $strMsgId_plural, $intNum, $strDomain */ public function setLanguage ($strLanguage, $strCountry); + /** + * Return the current locale setting as a string. + * + * @return string + */ + public function getLocale(); + /** * Tell us where to find the translations for a particular directory. Some translators will support multiple * charsets, and some only UTF-8.