[Solved] How to give out the Current Language
As the Title said, i really would like to know if there is a var which can give out the language code like "en_EN" based on the current settings.
Best Answers
-
peregrine MVP
since you really haven't explained the issue as your title and text says briefly.
do you mean the language code you set in vanilla or with your server php?
can be two different things
for vanilla
the conf/config.php shows the locales you set.e.g.
$Configuration['Garden']['Locale'] = 'en-CA';you could try this I haven't tested - but probably works.
$mylocale = Gdn::Config("Garden.Locale");
echo $mylocale;
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
6 -
peregrine MVP
here's another way...
echo Gdn::Locale()->Current();
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
6
Answers
since you really haven't explained the issue as your title and text says briefly.
do you mean the language code you set in vanilla or with your server php?
can be two different things
for vanilla
the conf/config.php shows the locales you set.
e.g.
$Configuration['Garden']['Locale'] = 'en-CA';
you could try this I haven't tested - but probably works.
$mylocale = Gdn::Config("Garden.Locale");
echo $mylocale;
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
The variable of the vanilla forum not the server.Thank you i will try this out and give you a feedback
Hmm wont work correctly. He only give out the German Language, but always. If i'm on english he says its german.
As example. html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de-DE". Is it possible that he is giving out my browser language instead of the language settings?
$mylocale = Gdn::Config("Garden.Locale");
echo $mylocale;
It's giving you exactly what the locale is set to in your config and works.
If I set my locale to german de-DE , it shows de-DE
if I set it to english en-CA it shows en-CA
Perhaps you are using some kind of plugin that you decline to mention.
Best I can help you with based on the information you provided.
if you are using some kind of multi language plugin, you would best be served by posting your question under the plugin rather than the general questions.
otherwise, what I told you is what I told you.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
here's another way...
echo Gdn::Locale()->Current();
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Great and Awesome Peregrine,
that did it now it works on all languages correctly.
Thank you very much
Great, don't be scared to click insightful on the reactions .
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.