Keycloak - Current language code in theme - themes

I would like to output the two letter language code (f.e. en) of the current language in the freemaker template of the login theme.
I already tried ${locale.current}, but this only outputs the name of the current language and not the code.

If you have enabled Internationalization for themes use:
${locale.currentLanguageTag}
${locale.currentLanguageTag} => en
${locale.current} => English

Related

Codeigniter Arabic language and rtl (right to left) stylesheet

I have a bilingual site, English and Arabic. Default language is Arabic and default loaded style.css is rtl. I switch the language with session and the translated text from language folder works correctly.
But for the second language (English) I have some issues:
When I am in About page and I switch language is goes to main page . How I can redirect to same page where I've been before switching language.
My function to switch language is:
public function change($type){
$this->session->set_userdata('lang', $type);
redirect(base_url());
}
After switching the language I need that also the stle.css for English language gets loaded.
In order to send the user to the same page between languages, you need to check which page the user is browsing, before invoking your function change($type)
You can get the current link like this:
$current_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
the redirect depends how your multi-language site is designed. It could be:
yoursite.com/ar
yoursite.com/en
or
en.yoursite.com
ar.yoursite.com
anyway basically you'll need to replace en with ar
the css change is easy to perform, just make use of the session you have created just before the redirect:
in the view file where you load the css, load the version depending on the session value of lang, make sure you use the default css, in case there is no session set (yet).

Magento price format showing wrong after changing language

Price formatting shows wrong after changing the default language English to another language.
In my main website it outputs like Rs.1,200,000.00 but after changing the language from English to another language its outputs like Rs.1.200.000,00.
How can I fix that issue?
You can change the priceformat in this file:
lib/Zend/Locale/Data/[lang].xml
You can search for:
<numbers>
<symbols>
<decimal>.</decimal>
<group>,</group>
</symbols>
</numbers>
Edit
changed folder name local to locale

Magento - Attribute display admin value in front end no matter what language i pick

In the back-end when managing the attribute from the attribute set i show him what text to display for the languages i have (Romanian And russian are currently active and important)
http://prntscr.com/32rhrm
However in the frontend as in Romanian Language so in Russian language it will layout the text that i input for the Admin in the attribute set
http://prntscr.com/32rhxz
how do i fix it?! how do i make it show the corresponding text for the needed language?
Thank you !!!

swapping rails3 layout on the fly

I have am trying to dig into twitter bootstrap and rails3 sites that actually look and function well (new to it all). I have this feature I want where I have a twitter bootstrap navigation (specified in what I guess is the default application layout) that calls a _navigation.erb.html etc. This works great, but on that navigation i want a "Se Habla Espanol" or what not, where when the user clicks there, the navigation text all changes to spanish. i thought easiest would be have another _navigationespanol.erb.html or something that changes the navigation words all around and also when click (toggling into spanish mode) it sets all the text in the pages to spanish by anytime there is a text render or whatever a variable flag was set and is interrogated on page index render show or what have you and it renders spanish or english words...
So ideally click on see it all in spanish, it loads a new layout (my main question) that has the spanish navigation and messages and other twitter bootstrap stuff and it also sets a global var i can look at in other renders to see if im rendering english or spanish.
More than swapping layouts, it seems that you need to implement Internationalization (I18n). In such case you'll have to create an directory config/locales that holds a .yaml file for each of the language you're trying to have translation for, for instance:
# on a file called en.yml
en:
hello: "Hello world"
For a complete guide on how to go about it: Rails Internationalization (I18n) API

Language is not changing in a component of Joomla

I am in the process of adding some lines of code to change the language automatically when the language is changed in the language selection module. One of my component in Joomla, it doesn't respect the language changing through language selection.
it's already the language.ini file is in the language directory is corresponding to this language. But the language is not changed. Is there any special joomla code to make it dynamic?
You should output text in Joomla like this:
echo JText::_("HELLO");
And you'll have to create an ini file with the language code and the name of the component/model. E.g.: en-GB.mod_modulename.ini. In this file you can define the translation for the string, like:
HELLO=Hola
When switching the language, the lines where JText is used, will display the correct language.

Resources