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.

Please make sure to update to WPML to the latest and check our list of Known Issues before reporting

This topic contains 11 replies, has 2 voices.

Last updated by Bigul 1 month ago.

Assigned support staff: Bigul.

Author Posts
February 19, 2020 at 12:04 pm #5523357

world-tradeD

Translate the strings of PHP functions

February 19, 2020 at 1:07 pm #5523969

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Somehow the chat got disconnected and all the chat history is cleared. Sorry about that.

Please let me know the string is showing for the translation or not now. If not, please share me your PHP code again.

--
Thanks!

Bigul

February 20, 2020 at 9:05 am #5530835

world-tradeD

Dear Bigul,
I had lost the chat page, sorry.

The change of code that you suggest is worse, because now the I see the function in front page too (!is_front_page doesn't work), and the problem is not solved because this string is not translatable.

I flag "Individua la posizione in cui appaiono le stringhe nel sito" but the string "indietro" is missing.

function section_before_footer() {
if(!is_front_page() )
$content = '<div class= "wtd-back-arrow">
<a href="#" onclick="history.go(-1)">
<button type="submit">←';
$content .= __('Indietro', 'section_before_footer' );
$content .= '</button>
</a>
</div>';

echo $content;

}
add_action('get_footer', 'section_before_footer');

Kind Regards

February 20, 2020 at 9:20 am #5530915

world-tradeD

Dear Bigul,
I put again my similar function, because your appear in home and it shouldn't, so the updated code to translate is (the word to translate is just "indietro"):

/*add back button before footer*/
function section_before_footer() {
if(!is_front_page() )
$content = '<div class= "wtd-back-arrow">
<a href="#" onclick="history.go(-1)">
<button type="submit">← Indietro</button>
</a>
</div>';

echo $content;

}
add_action('get_footer', 'section_before_footer');

I have to traslate also benvenuto=welcome in this function.php:

/*add shortcode [show_loggedin_as] so when you are logout the word is "login", instead if you are login: your name*/
function show_loggedin_function( $atts ) {

global $current_user, $user_login;
get_currentuserinfo();
add_filter('widget_text', 'do_shortcode');
if ($user_login)
return '<a href="/private-area"> Benvenuto ' . $current_user->display_name . '</a>';
else
return '<a href="/wtd-login">Login</a>';

}
add_shortcode( 'show_loggedin_as', 'show_loggedin_function' );

February 20, 2020 at 12:07 pm #5532731

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Thank you for the updates. Please try with the following code after a site backup. I hope you are adding this code in functions.php of your theme.

function section_before_footer() {

	$content = '';

	if(!is_front_page() ){

		$str = __('Indietro', 'custom_theme_strings' );

		$content = '<div class= "wtd-back-arrow">
				<a href="#" onclick="history.go(-1)">
					<button type="submit">←'.$str.'</button>
				</a>
		</div>';
	}

	echo $content;

}
add_action('get_footer', 'section_before_footer');

function show_loggedin_function( $atts ) {

	global $current_user, $user_login;
	get_currentuserinfo();
	add_filter('widget_text', 'do_shortcode');
	$login = __('Benvenuto', 'custom_theme_strings' );
	$logout = __('Login', 'custom_theme_strings' );
	if ($user_login)
	return '<a href="/private-area">'.$login." ".$current_user->display_name.'</a>';
	else
	return '<a href="/wtd-login">'.$logout.'</a>';

}
add_shortcode( 'show_loggedin_as', 'show_loggedin_function' );

Then please try the following steps and make sure you are getting the expected result or not

1) Visit WPML>>Theme and plugins localization
2) Scroll down to *Strings in the themes* section
3) Choose the theme and click on *Scan selected themes for strings* button
4) Wait until the scan complete
5) Visit WPML>>String Translation and translate the strings

May you have to change the language of these newly added strings to Italian, if your site's string language is English. Please check the following documentation for more details.

https://wpml.org/documentation/getting-started-guide/string-translation/#original-language-of-strings

--
Thanks!

Bigul

February 21, 2020 at 11:54 am #5540077

world-tradeD

Dear Bigul,
I did everything that you wrote (I put your php in my function, and I worked on wordpress), but the result is the same: the php are still missing.

Look at attached screenshot.

Have you got new ideas?

Kind Regards

February 21, 2020 at 12:56 pm #5540625

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Thank you for the updates. I hope you are getting the correct result for the modified code in the frontend(except the string translation). Because I am getting the expected result in my local copy. Please check the attached images.

Please fill the private details fields after a full site backup. I would like to access the admin area of your site for further checking.

Please check the following links for more details about our private information sharing policies.

https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

hidden link

--
Thanks!

Bigul

February 24, 2020 at 1:49 pm #5555055

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Thank you for the updates. The code is working as expected in my local copy. Please check the following images.

https://wpml.org/wp-content/uploads/2020/02/5540625-2020_02_21_1828.png

https://wpml.org/wp-content/uploads/2020/02/5540625-2020_02_21_1827.png

Therefore please try the following steps and make sure you are getting the expected result or not

1) Visit WPML>>Theme and plugins localization
2) Scroll down to *Strings in the themes* section
3) Choose the child theme and click on *Scan selected themes for strings* button
4) Wait until the scan complete
5) Visit WPML>>String Translation and translate the strings

May you have to change the language of these newly added strings to Italian, if your site's string language is English. Please check the following documentation for more details.

https://wpml.org/documentation/getting-started-guide/string-translation/#original-language-of-strings

--
Thanks!

Bigul

February 26, 2020 at 7:58 am #5568319
world-tradeD

Dear Bigul, I did what you said: it's true, in this way the word appears and I can translate also php string, but the result was disastrous.

All the pages of the website disappear, the only way to see again the website is deactiving "WPML Multilingual CMS".

This is my theme:hidden link
and as you see it 's compatible with WPML.

I need to translate php words and to have a website not down.

Look at attached screenshots.

Kind Regards

New threads created by Bigul and linked to this one are listed below:

https://wpml.org/forums/topic/_icl_strings-table-does-not-exists/

February 26, 2020 at 10:42 am #5569767

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Thank you for the feedback. In the first look, the new issues are not happening because of the changes we have made in the functions.php of child theme and scanning the theme strings for translation.

Therefore I have opened a new ticket for it. Because as per our support policies, we can only handle one issue per ticket. It will help us to serve you better and we can avoid discussing multiple problems in one ticket. Also, it will help other users with similar problems find solutions when searching the forum. I will get back to you soon on the new ticket. Please wait. Thank you for your understanding.

--
Thanks!

Bigul

February 26, 2020 at 11:34 am #5570403

world-tradeD

This?
https://wpml.org/forums/topic/_icl_strings-table-does-not-exists/

Thanks

February 26, 2020 at 12:15 pm #5570845

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Thank you for the updates. Yes, please visit the following ticket URL and update the status there. So we can avoid discussing multiple issues in one ticket.

https://wpml.org/forums/topic/_icl_strings-table-does-not-exists/

--
Thanks!

Bigul

The topic ‘[Closed] Translate the strings of PHP functions’ is closed to new replies.