0

I am using a qtranlate wordpress plugin, i want to get current page language for if statement but the function is not working in giving me this error:

Fatal error: Call to undefined function qtrans_getLanguage() in /my_theme_path_url/templates/app_header.php on line 46

this is my code which i am using and the plugin is active.

<?php if( qtrans_getLanguage() == 'ar' ){ ?>
        <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>offplan-projects/">جميع المشاريع</a></li>
        <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>developers/">المطورون</a></li>
        <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>developments/">التطورات</a></li>
    <?php }
        elseif( qtrans_getLanguage() == 'ru' ){ ?>
        <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>offplan-projects/">Все проекты</a></li>
        <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>developers/">Разработчики</a></li>
        <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>developments/">события</a></li>
    <?php }
        elseif( qtrans_getLanguage() == 'zh' ){ ?>
        <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>offplan-projects/">所有项目</a></li>
        <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>developers/">开发人员</a></li>
        <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>developments/">的发展</a></li>
    <?php } 
        else{ ?>
        <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>offplan-projects/">All Projects</a></li>
        <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>developers/">Developers</a></li>
        <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>developments/">Developments</a></li>
    <?php }?>

any help appreciated. Thanks

Sajjad Ahmad
  • 143
  • 3
  • 17
  • Where you using this code? And for such things I recommend to use an cleaner way: Read [this](https://codex.wordpress.org/I18n_for_WordPress_Developers) and [this](https://developer.wordpress.org/themes/functionality/internationalization/). – Andy Tschiersch Feb 16 '17 at 12:55
  • @AndyTschiersch i am using this in header.php but i found the solution, the function i am using is renamed. qtranxf_getLanguage() – Sajjad Ahmad Feb 16 '17 at 13:13

1 Answers1

1

In the documentation of qtranslate is mentioned that for functions in my_theme or plugins

"qtrans_ were renamed to have prefix qtranxf_"

to prevent conflicting function names:

https://qtranslatexteam.wordpress.com/faq/