This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 9 replies, has 2 voices.

Last updated by patagonialandU 11 months, 4 weeks ago.

Assigned support staff: Laura.

Author Posts
October 17, 2018 at 11:15 am #2824345

patagonialandU

Tell us what you are trying to do?

I am trying to translate a button (and Pop Up it shows when clicked) at the top menu "FALE CONNOSCO".
This button and PopUp are a shortcode from the plugin Convert Plus.

I created two convert Plus Pop Ups - One for portuguese and another for english.
Each one has it's own shortcode.

And now I want to show each one in the right Language.

I am using The7 Theme, and this theme gives me the option for inserting shortcodes in "microwidgets" besides the navigation area.

This is how I created the button "FALE CONNOSCO" and the language switcher that you can see at the top of the page, besides the menu.

The language switcher is changing automatically.

But I need to know how I can get the Convert Plus shortcode for Portuguese version when in Portuguese version, and how to get the English Shortcode in the english version.

Is there a way to get one shortcode if I am in English, and another if I am in the Portuguese version?

What is the link to your site? dev.compuworks.pt

Any clues would be appreciated.
Thanks for helping,
Margarida

October 18, 2018 at 1:52 pm #2828188

Laura
Supporter

Languages: English (English ) Italian (Italiano ) Portuguese (Brazil) (Português )

Timezone: Europe/Rome (GMT+02:00)

Hi Margarida,

I don't understand if those "microwidgets" are real widgets or not. I mean, they do appear in Appearance -> Widget?

If so, you should be able to create 2 different widgets, and display them one in English and one in Portuguese, or be able to translate them in String Translation.
See our documentation: https://wpml.org/documentation/getting-started-guide/translating-widgets/

If this doesn't help you, I may ask for your site's credential as I don't know how this plugin works so I may need to look further.

October 18, 2018 at 3:16 pm #2828468

patagonialandU

The problem is that this is not a regular widgets.
It is a special setting in the theme where I can add mini widgets to the header and menu.

I was looking for something more in PHP like

if lang=EN_uk {
do this
}
if lang=PT_pt {
Do something else
}

Is there a PHP code to do this with WPML?

Thanks.

October 19, 2018 at 6:28 am #2830599

Laura
Supporter

Languages: English (English ) Italian (Italiano ) Portuguese (Brazil) (Português )

Timezone: Europe/Rome (GMT+02:00)

Hi,

you can check our hook page: https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/
Unfortunately, this is custom coding and that goes beyond our support policy (you can find it here: https://wpml.org/purchase/support-policy/) so I can't be of much help.
You can also try to contact one of our WPML contractors to help you. See here: https://wpml.org/contractors/

However, I think you should be able to find the string in String Translation or in the string admin page (the link is at the bottom of the String Translation page) so custom coding may not be necessary.

October 23, 2018 at 10:49 am #2841867

patagonialandU

I just need to know how to show an IF EN { do this } IF PT { do something else }
The link you gave me is for much more complicated function than what I am asking.

There must be some more help you can give me...

October 23, 2018 at 11:23 am #2841949

Laura
Supporter

Languages: English (English ) Italian (Italiano ) Portuguese (Brazil) (Português )

Timezone: Europe/Rome (GMT+02:00)

Hi,

we don't have hooks for specific languages. You'd need to register them. Otherwise, you can try with this: https://wpml.org/wpml-hook/wpml_current_language/ to retrieve the current language and call for your element in that specific language.

But again, I'd give a try with String Translation first, if you didn't do it yet.

October 23, 2018 at 11:29 am #2841993

patagonialandU

Does this function still exist:
if ($lang == 'pt')
elseif ($lang == 'en')

Or is it:
$ICL_LANGUAGE_CODE

Thanks

October 23, 2018 at 3:24 pm #2843276

patagonialandU

I tried this in functions;

$my_current_lang = apply_filters( 'wpml_current_language', NULL );
if ($my_current_lang == 'pt-pt') { ?>
	<style type="text/css">
		.cta-pt { display: inline;}
	</style>
<?php } else { ?>
	<style type="text/css">
		.cta-pt { display: none;}
	</style>
<?php
}
if ($my_current_lang == 'en') { ?>
	<style type="text/css">
		.cta-en { display: inline;}
	</style>
<?php } else { ?>
	<style type="text/css">
		.cta-en { display: none;	}
	</style>
<?php
}

But this gives an error in Debug:
PHP Warning: Cannot modify header information - headers already sent by (output started at /home/compuworks/public_html/wp-content/themes/dt-the7-child/functions.php:56) in /home/compuworks/public_html/wp-includes/pluggable.php

It is working but this might not be the right place to put this code.

Can you help me find out where is the best place for it?
Thanks

October 24, 2018 at 8:40 am #2845328

Laura
Supporter

Languages: English (English ) Italian (Italiano ) Portuguese (Brazil) (Português )

Timezone: Europe/Rome (GMT+02:00)

Hi,

I'm sorry, but as you see from the error, the problem is with the theme and not with WPML code. You should ask the theme developer for suggestions about where to place custom code.

October 28, 2018 at 4:13 pm #2856292

patagonialandU

I solved it by myself. The problem was in the code. Not the theme.