Okay
  Public Ticket #1224701
Multi-Language - Use of WPML Plugin
Closed

Comments

  •  2
    mobiz-at started the conversation

    We need our website in 2 languages (german + english) and have installed the WPML Plugin for the translations.

    This works fine for the pages and posts.

    Certainly we also need to translate the contents/text in the footer as well as for the blog page under http://mobizdev2.aix-cloud.de/blog/

    However, we haven't found any options or fields in the theme options/settings section where we can enter the translated texts. Obviously the WPML Plugin does not hook in the theme options panels.

    See the screenshots attached.

    Can you please provide us with a solution to fix this issue, e.g. via additional code to insert into functions.php or other files of the theme.

    Thanks in advance!

    Best,

    Wolf.


  •  2
    mobiz-at replied

    I've searched a bit in the WPML forums and found out that translations might be also possible to make via their "String Translations" options, if the texts to be translated are wrapped in GetText calls:

    https://wpml.org/faq/language-setup/


  •  840
    Jelly replied

    Hi,

    You can use this function:

    <?php // wpml shortcodes --------------------
    add_shortcode( 'wpml_language', 'wpml_find_language');
    /* ---------------------------------------------------------------------------
     * Shortcode [wpml_language language="en"] [/wpml_language]
     * --------------------------------------------------------------------------- */
    function wpml_find_language( $attr, $content = null ){
        extract(shortcode_atts(array(
            'language' =--> '',
        ), $attr));
        $current_language = ICL_LANGUAGE_CODE;
        if($current_language == $language){
            $output = do_shortcode($content);
        }else{
            $output = "";
        }
        return $output;
    }
    

    Then you can use it like this:

    [wpml_language language="en"]Text for EN [/wpml_language]
    [wpml_language language="xx"]Text for other language [/wpml_language]
    

    Best Regards,
    Jelly Team