Gettext icon indicating copy to clipboard operation
Gettext copied to clipboard

Cannot translate long string

Open W3b3r opened this issue 7 years ago • 8 comments

Hi guys,

i'm already using this sdk, and works very well.

I have a little issue in some case the translation, some string don't become translated. For example i have a string that have 931 characters and don't begin translated.

Thanks in advace for help Best.

W3b3r avatar Dec 11 '18 16:12 W3b3r

Hi, can you provide a test case reproducing this error?

oscarotero avatar Dec 11 '18 17:12 oscarotero

Hi oscar,

thanks for your response.

here is an example of text that is not translated.

I call a text from database and include variable and become like this.

Here is the text Coperta in pile per letto singolo disponibile con retro nel colore indicato. Elemento di Garanzia e' la lavorazione artigianale, tipica del Made in Italy. Le nostre coperte in pile sono realizzate singolarmente a mano e le cuciture vengono controllate scrupolosamente prima di essere spedite. Utilizziamo solo inchiostri a base acqua, assolutamente atossici e non dannosi per l'ambiente e le persone. Tutti i prodotti sono lavabili sia a mano che in lavatrice, ad una temperatura ideale di 30 gradi. Per ottenere un lavaggio ottimale e' consigliabile utilizzare un detersivo delicato per capi colorati ed impostare una bassa velocita' di centrifuga. Per conservare al meglio la brillantezza della stampa e' preferibile lasciare asciugare il prodotto all'aria aperta, evitando l'esposizione diretta a fonti di calore, soprattutto termosifoni e caloriferi. Tessuto 100% Poliestere. Dimensione Prodotto 155x100 cm.Spessore 1 cm circa.

W3b3r avatar Dec 13 '18 13:12 W3b3r

Can I see the php code in which the variables are included?

oscarotero avatar Dec 13 '18 15:12 oscarotero

I noticed that with extra long texts it does not work. The tag is correct... Here is my php code

`<?php include_once(".../gettext/autoloader.php"); include_once("../gettext-helper/autoloader.php");

use Gettext\GettextTranslator;

//Create a new instance $translate = new GettextTranslator();

$translate->setLanguage("en_US");

//Load the domains: $translate->loadDomain('messages', '.../Locale'); //this means you have the file "../Locale/en_US/LC_MESSAGES/messages.po" $translate->register();

$mysqli = new mysqli(DBHOST, DBUSER , DBPASSWORD, DBNAME); $query_db = $mysqli->query(" SELECT description FROM products WHERE...."); $query = $query_db->fetch_assoc();

echo __($query["description"]); ?>`

I also increase memory limit on the server with no success.

W3b3r avatar Dec 13 '18 15:12 W3b3r

This library is not correctly used here. __($query["description"]) makes no sense, why don't simply save the different descriptions in the database? For example:

$query_db = $mysqli->query(" SELECT description_en as description FROM products WHERE....");
$query = $query_db->fetch_assoc();
echo $query['description'];

Doing it as in your example, you must be sure that messages.po contains a string that matches exactly with the description text you put above, and don't change this text in the dabase anymore, so it's a really bad idea.

oscarotero avatar Dec 13 '18 15:12 oscarotero

Thanks Oscar, I already know this critical issues.. I already check this possibilites the tag is present in mesages.po i never change description in database.

W3b3r avatar Dec 13 '18 15:12 W3b3r

I guess this issue is due any character that is different in po and db (a white space or something like this).

oscarotero avatar Dec 13 '18 16:12 oscarotero

Ok i'm going to check again this possibilites. Thanks for your support. Best.

W3b3r avatar Dec 13 '18 16:12 W3b3r