Jump to content

Recommended Posts

not sure if is the right section to post here

 

its a long message but its all info mostly:

this is the code that i use to get the value of $i['message'] -> the message that the user types in chat and sends to the other user, and i used google api and translated it

 

$en_to_es = '';
$es_to_en = '';

try {
	$gt = new Gtranslate;


//	$es = str_replace("\n", "<br>", $message);
	$es = strip_tags($message);
	$es = $gt->english_to_spanish( $es );
	#$es = html_entity_decode( $es );

    $en_to_es = mysql_real_escape_string( $es );


//	$en = str_replace("\n", "<br>", $message);
	$en = strip_tags($message);
	$en = $gt->spanish_to_english( $en );
	#$en = html_entity_decode( $en );

    $es_to_en = mysql_real_escape_string( $en );

} catch (GTranslateException $ge) {
	echo $ge->getMessage();
}		

 

the thing is this

for example i type in english: how are you ?  (notice the space between you and ?)

the message that is sent looks like this (coded with fonts, etc):

<font face="Verdana, Arial" color="#000000" style="line-height: 22px; font-size: 12px;" />how are you ?</font />

(notice it inserts it with the space)

 

but the code for the translation that i used inserts the code like this:

 

en_to_es -> ¿cómo estás?
es_to_en -> how are you?

 

notice the space in these 2 ?

is stick to the text

and cause of this when i get the code from the database to compare it to the translation in the database to see if it matches to show the apropriate translation for it its not working cause the original mesage had the space and the text with the translation removes the last space before ?

 

this is the code i use to compare the original message that the user sent and its translations

if (strip_tags($i['message']) == strip_tags($i['en_to_es']) )
	{
			$spanish = '1';
	}
if (strip_tags($i['message']) == strip_tags($i['es_to_en']) )
	{
			$english = '1';
                }

 

so i guess my error is somewhere here:

// $es = str_replace("\n", "<br>", $message);

$es = strip_tags($message);

$es = $gt->english_to_spanish( $es );

#$es = html_entity_decode( $es );

 

    $en_to_es = mysql_real_escape_string( $es );

 

 

can u help on how and what to use to keep the original formating of the message, refering to the space or no space after word and exclamation marks

 

thanks so much

Link to comment
https://forums.phpfreaks.com/topic/177929-small-php-data-compare-issue/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.