Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot translate long string #196

Open
W3b3r opened this issue Dec 11, 2018 · 8 comments
Open

Cannot translate long string #196

W3b3r opened this issue Dec 11, 2018 · 8 comments

Comments

@W3b3r
Copy link

W3b3r commented Dec 11, 2018

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.

@oscarotero
Copy link
Member

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

@W3b3r
Copy link
Author

W3b3r commented Dec 13, 2018

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.

@oscarotero
Copy link
Member

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

@W3b3r
Copy link
Author

W3b3r commented Dec 13, 2018

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.

@oscarotero
Copy link
Member

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.

@W3b3r
Copy link
Author

W3b3r commented Dec 13, 2018

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.

@oscarotero
Copy link
Member

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

@W3b3r
Copy link
Author

W3b3r commented Dec 13, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants