I have created a Wordpress theme that needs to be in German and English. In the navigation I have a button which should change the language depending on what language they are currently using. (If they are viewing the english page it should display "Deutsch" and vice versa.)
I'm using qTranslate Plus and have chosen to display the language code in the url (/de or /en). My main problem lies when I'm on a custom page (Wordpress page with a template) (/custom-page) and change the language it doesn't change to german although in the source code the link displays /de/custom-page. It completely ignores the language code and takes me to /custom-page again. So it seems to be stripping the language code out.
Is this standard Wordpress behaviour and if so, how can I disable it? Also is there a better, more reliable way to change the language? Would storing the language in a session work?
Note: Both "Hide untranslated content" and "Hide URL language information for default language." are unchecked.
Thanks in advance, Peter
I had a similar issue on a site I was working on. I installed this extension which seemed to resolve some issues with URLs
https://wordpress.org/plugins/qtranslate-slug/
alternatively, you could target the button with javascript/jQuery using conditional statements to detect the html lang attr. Something like this:
var lang = document.documentElement.lang;
if (lang == 'en-US'){
$('button').html('your button text')
}
qTranslate is not supported well. If you just started implementing it I think you should give other plugins a shot. Here are few replacements for qTranslate: mqTranslate and zTranslate. Both are qTranslate forks so you shouldn't loose anything.
As for your question you can simply hide current language with css using lang selector:
:lang(current languagecode) {
display: none;
/*the other way to hide things*/
text-indent: 9999px;
overflow: hidden;
}
Hope this helps.
Best Regards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With