Support » Plugin: mqTranslate » Option to display default content if no translation available

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author chsxf

    (@chsxf)

    Such a feature is already available in the plugin.

    Uncheck “Hide Content which is not available for the selected language. ” on the mqTranslate Settings page and the default content will be displayed for missing elements.

    Hi chsxf,
    I’ve done what you have suggested but I don’t see the default content, I get the notice “Sorry, this entry is only available in %LANG”. How can I display default content for missing elements?
    Thanks for your attention and your great job,
    C.

    Hi,

    Firstly, thanks chsxf for continuing to answer support questions. That feature: UncheckHide Content which is not available for the selected language.” is not working on new posts either even after checking on “Hide Untranslated Content” and selecting the choice of “click here to mark all existing posts as written in the default language” in Convert Database.

    @chsxf, can you please guide further because I have almost 900 posts in local language and my default language is local itself.

    Thanks.

    I hust had the same problem, and after some digging in the source code of the plugin, I found a clean solution. In your functions.php file, add the following two lines:

    remove_filter('the_content', 'qtrans_useCurrentLanguageIfNotFoundShowAvailable', 0);
    add_filter('the_content', 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage', 0);

    Pretty self-explanatory, right? 😉 …and to hide the (sometimes not very useful) language in brackets if displaying the default language, also add this line:

    update_option('mqtranslate_show_displayed_language_prefix', '0');

    EDIT #1:
    Of course, you can do the same for the_excerpt and the_excerpt_rss. Just duplicate the lines above and replace "the_content" with "the_excerpt" or "the_excerpt_rss".

    A good place to find all available (m)qtranslate hooks is in the file mqtranslate_hooks.php.

    EDIT #2:
    Maybe it would be a good idea to hide the language in brackets for normal visitors, but to show it to logged in users, so that they have a hint that content is untranslated. Put this in your function instead of the update_option line above (that way you will also save one database call):

    global $q_config;
      if( current_user_can("edit_posts") ) {
        $q_config["show_displayed_language_prefix"] = true;
      } else {
        $q_config["show_displayed_language_prefix"] = false;
      }

    Plugin Author chsxf

    (@chsxf)

    You can remove the language prefix in brackets using the Settings > Language specific option:
    “Show displayed language prefix when Content is not available for the selected language.”

    @chsxf:

    that’s right, never found this, thank you! Still, I like to set things from my theme’s functions.php, so that I don’t have to remember all settings for the next time I install it somewhere.

    By the way: Thank you so much for your amazing effort with mqtranslate!!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Option to display default content if no translation available’ is closed to new replies.