-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option for showing post in default language if translation not available #21
Comments
Hi Zeus, please describe the details. Which admin page exactly do you mean, for example? |
Hi John, I'm sorry. I meant for an extra checkbox in the qTranslate Configuration page which could enable "Show complete post/page in default language when a translation is not available (even though the user chose another language)". Currently it's only configurable when a translation is not available to show a link to the post in another language or to hide the post complety for the unavailable language. When I choose the first configuration, I find what I'm looking for is already implemented in the title of the post. So I was hoping this could perhaps be implemented for the body of the post too. |
You mean configuration option in admin, which controls how it is shown on front-end? You do not mean to load default language to the editor in back-end instead of empty text, do you? As showing at front end, sometimes there are a few languages available with translation, and links to all of them show up. Which language would you display then? A visitor of a site is not aware of the concept of 'default language' and may be puzzled why some particular language is shown over others available. Links treat all languages equally and offer user to choose by clicking one of them. How would you deal with this? |
It is for the front-end and I understand it's not a very common use case. The idea behind this is that a large part of our userbase uses browsers in English (on the university), while they still speak our default language. We only support two languages, so I'd like to save them the time of loading another page. Even more, I've found that Google indexes the empty English pages, while I would still like the content to be found on Google, even when searched for in our default language. We used to accomplish this by filtering qtrans_postsFilter. Perhaps you could help me with which function would be best to create a filter or a hook for. Also with regard to compatibility with future releases. Thank you! |
It makes perfect sense on the sites with two languages. Why function postsFilter? Search for Do you wish to implement it and to submit pull request? |
Ok great! I would wish I could, but unfortunately I don't have the time at the moment. |
Yeah, the things are hectic for me too now. Let us keep it open, some day we will add that in. |
In a bilingual project, I need to show posts in chosen language, or in alternate language if not available, with no additionnal messages. Replacing $q_config['not_available'][$lang] with $lang_text on line 1306 at the end of the qtranxf_use_block function in qtranslate_core.php works well for this. As I am relatively new to WordPress, I do not know how to permanently override this in my child theme's function.php - any help would be appreciated. |
Hello and thank you for that great and useful plugin ! :) Any news of that default language update ? I could make use of it. ;) I tried the PHP modification qtranslate_core.php, but can't get the desired result... If you have another solution while waiting for the Plugin update i'm interested. ^^ Thank you. |
I ended up doing something a bit different in qtranslate_core, since that last change did not work in some instances. Replace last line in same use_block function (french and english in this example) :
|
Hi Delorimier, Thank your for that fast reply ! :) I must replace that block ? : if(!$show_available){ }Sorry but it seems difficult for me to find which part to replace. Here is the full block: if (!function_exists('qtranxf_use_block')){
} }If i have multiple languages i must duplicate your block and edit the portion "if ($lang == 'fr'){". The main language of the site is French and is translated in English, German, Portuguese 4 others. Thank you for your help ! :) |
Or maybe here ? //qtranxf_dbg_echo('$language_list=',$language_list,true); ".preg_replace('/%LANG:([^:]):([^%])%/', $language_list, $q_config['not_available'][$lang])." ";} } |
Replace line 1388 in current version with code provided in my earlier response.
English content should then be shown when French content is not available, and vice-versa. Hope this works for you. Just change "en" and "fr" with you own language codes (en is main language on my site). Keep a copy, these changes will be overwritten following plugin updates. I see you have multiple languages, I guess you can make it work with more if else statements - you can use $content['en'] instead of $lang_text on that last line. |
What needs to happen exactly if selected language content is not available? Show main language (french)? Is french content always available? In that case, this line only should work (replacing 1388 line):
Or maybe:
|
Hello Delorimier, Thank you for your help. I wanted the plugin to redirect the visitor to French page if this page in the visitor langage is not available. This is for an event calendar which i want to update only in one langage. This line seems to do the trick !
";
I'm testing around, will tell you if something goes wrong. Thanks again Man ! :) |
I finalized it together with the new option "Show content in an alternative language" in the latest on GitHub. Please, test it all with various number of available languages, single post view, search view and all other kind of applicable views. The pre-content message differs depending on the number of languages available and whether or not the alternative language is the default one. Altogether, there are four different cases. The messages may need to be polished a bit more, this is the most difficult part of this change. |
I like what you did with qtranxf_use_block! Thank you for making this truly happen. Works as expected with two languages. The additional messages are also really nice. Perhaps it's an idea to change "For the sake of viewer convenience, the content is shown below in the alternative language." to "For your convenience, it is shown below." as to not distract too much from the content. Also shouldn't we have to mention the language that is used in this case?: 'For the sake of viewer convenience, the content is shown below in an available alternative language.' Perhaps something like 'For the sake of viewer convenience, the content is shown below in the first available language, %s.' is a good idea? |
In the code, you may find commented lines with '%s'. When I tried it, the language name was repeated twice in two sentences following each other. It looked a bit crowded, so I deleted %s, but I am not really sure about the best way. Uncomment lines to see how it looks. Do you like it? |
This issue can probably be closed now. We can continue discussion under closed issue, and may re-open it, if needed. |
Thank you for the optimizations John. 👍 |
Thanks again for the work developing this plugin, it's very useful .However, and following the request of this issue, I would appreciate the option to show or hide the language warning: "For the sake of viewer convenience, the content is shown below in the alternative language", and "You may click the link to switch the active language". It can be fine to warn the user about the post not in a certain language, but in my case it is obvious, and I'd rather not showing any message at all, just the post itself. Thanks! |
Hi, +1 for the suggestion of @xabispacebiker In the meantime I disabled the message in the frontend by adding this to the Theme's Stylesheet
|
@tarator THANK YOU!!!!!!!!!!!!!!!!!!! |
Hi qTranslateTeam,
First, thank you for your great work! Since I found that this plugin is actively developed, I'll try to do a feature request.
I would be very pleased to see an option in the admin panel to also show posts in the default language when a translation is not available. Currently, (if I'm correct) this is only possible for the title of the post.
Something like this would be perfect:
to:
Thanks!
The text was updated successfully, but these errors were encountered: