Title: Translating header part with code placement plugin
Last modified: November 17, 2016

---

# Translating header part with code placement plugin

 *  [CrackInfoTante](https://wordpress.org/support/users/crackinfotante/)
 * (@crackinfotante)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/translating-header-part-with-code-placement-plugin/)
 * Hi,
 * great Plugin!!
    I’ve following question: I try to create an if/else php statement
   through the plugin “easy code placement”. I put some content in the header through
   this “code placement plugin” and it’s not translated automatically when I click
   on the language switch button. That’s why I want to write an if/else code in 
   order to translate this header part. I tried following solutions to add into 
   the code placement plugin:
 *     ```
       <?php
       global $sublanguage;
       $name = echo $sublanguage->current_language->post_name;
       if($name == 'en'){
   
              print "english text";
           }
             print "german text";
       } ?> 
       ```
   
 * OR
 *     ```
       <?php
       $Id = echo get_permalink($post->ID);
           if ($Id == 'eng') {
   
               return 'english text';
           }
           return 'german text';
   
       } ?> 
       ```
   
 * OR
 *     ```
       <?php
       function my_custom_translation($original_text, $current_language, $optional_arg) {
   
           if ($current_language->post_name == 'eng') {
   
               return 'english test';
           }
           return $original_text;
   
       } ?>
       ```
   
 * Unfortunately nothing works – what do I wrong? I tried to follow the FAQ supports…
 * I would be very very greatful if someone could help me.
 * Thank you!!

Viewing 1 replies (of 1 total)

 *  [maxime](https://wordpress.org/support/users/max345/)
 * (@max345)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/translating-header-part-with-code-placement-plugin/#post-8447989)
 * Hello,
 * I think you’re almost there:
 * #1:
 *     ```
       <?php
       global $sublanguage;
       $name = $sublanguage->current_language->post_name;
       if($name == 'en'){
   
              print "english text";
           }
             print "german text";
       } ?> 
       ```
   
 * #3:
 *     ```
       <?php
       function my_custom_translation($original_text, $current_language) {
   
           if ($current_language->post_name == 'eng') {
   
               return 'english test';
           }
           return $original_text;
   
       } 
   
       echo apply_filters('sublanguage_custom_translate', 'text to translate', 'my_custom_translation');
   
       ?>
       ```
   
 * Forget about the #2. I think the #3 is better, even if it looks a bit more complex,
   because it will still work if you uninstall Sublanguage. The solution #1 will
   crash as soon as you remove sublanguage.

Viewing 1 replies (of 1 total)

The topic ‘Translating header part with code placement plugin’ is closed to new 
replies.

 * ![](https://ps.w.org/sublanguage/assets/icon-128x128.png?rev=1197494)
 * [Sublanguage](https://wordpress.org/plugins/sublanguage/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/sublanguage/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/sublanguage/)
 * [Active Topics](https://wordpress.org/support/plugin/sublanguage/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sublanguage/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sublanguage/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [maxime](https://wordpress.org/support/users/max345/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/translating-header-part-with-code-placement-plugin/#post-8447989)
 * Status: not resolved