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

Duplicated messages #443

Closed
EMAD08 opened this issue Feb 6, 2019 · 34 comments
Closed

Duplicated messages #443

EMAD08 opened this issue Feb 6, 2019 · 34 comments

Comments

@EMAD08
Copy link

EMAD08 commented Feb 6, 2019

I usually use this plugin with every website I create, but in the last one it started to duplicate and triplicate the messages on the "Translate messages" section, I can't figure it out

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019

The new version allows the CMS pages fields to be translated directly in the page editor, there is no need for the "Translate messages" anymore for the title, description, meta-title and meta-description.

Are the messages that gets duplicated in one of those fields? Can you give examples with as much details as possible?

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

The new version allows the CMS pages fields to be translated directly in the page editor, there is no need for the "Translate messages" anymore for the title, description, meta-title and meta-description.

Are the messages that gets duplicated in one of those fields? Can you give examples with as much details as possible?

Thank you mjauvin for you reply, the messages are not from the fields you mentioned, they are from photo descriptions that I use for alt-text, in my markup I use it like this: {{ photo.description|_ }}

I attached a screenshot of how the "Translate Messages" section looks like.

translate-duplicated

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019 via email

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

Here it is
alt-text

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019 via email

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

FileUpload

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019 via email

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

I'm using 2, English and Spanish.

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019 via email

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

Ok, thank you very much!

@munxar
Copy link
Contributor

munxar commented Feb 7, 2019

How long is the text that you use as key? Is it longer than 255 chars?

Can you post the records from the DB table (translate_mesaages) with all columns of one example that has many entries?

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

Some of the messages are longer than 255 chars, but even the ones that aren't get duplicated

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019 via email

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

Sure, these are some messages that are getting duplicated (Just some, as almost every message has that bug)

Bold 100% Cotton Table Cloth with unique and original Aroate design.2 meters x 2 meters - $40.00 #43160 cm x 3 meters - $40.00 # 44160cm x 2.5 meters - $40.00 #45160cm x 2 meters - $35.00 #46160cm x 160cm - $35.00 #47

Arte Seni Luna designs and crafts their unique lamps from natural clay and fires them in their on-site kiln. Choose from a variety of designs that reflect the traditions, styles and craftsmanship of Oaxaca. $35.00 US Dollars each with light fixture and shade - L to R #12 House, #13 Stars, #14 House, #15 Small House, #16 Pyramid & #17 Geometric Design.

A uniquely-designed rose-colored Huipil cover-up to complement a blouse, sweater or dress. The open-front design and intricate floral and geometric patterns make this handcrafted Huipil a very fashionable addition to your wardrobe! $120.00 US Dollars #17

A light blue cotton vestido/dress with intricate hand-stitched orange flowers and accent lines adorn the front, neckline and bottom. A very comfortable, fashionable and and traditional dress from Tlahuitoltepec .-$185.00 US Dollars #16

A delicious and traditional dish from Oaxaca of chicken covered with a rich, smooth and Mole Negro with Rice and Tortillas! Order a Liter of Isabel's delicious Mole Negro for only $15.00 US Dollars. You will Love It!!! #1

Lamb's Wool Socks. $12.50 #31

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019

@munxar the table definition for translate messages is below, the "code" column is actually 192 chars:

Create Table: CREATE TABLE rainlab_translate_messages (
id int(10) unsigned NOT NULL AUTO_INCREMENT,
code varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
message_data mediumtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (id),
KEY rainlab_translate_messages_code_index (code)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

@munxar
Copy link
Contributor

munxar commented Feb 7, 2019

Each time you change the text, you'll get a new entry, because the code changes. It should be unique.

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

So that means that all the messages that have 191+ chars are getting duplicated?

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019

I was able to replicate the issue using much longer text. I'll try to find the actual treshold where this happens...

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019

@EMAD08 You were saying you used this before without getting this behavior... did you use texts as long as the ones for the current project?

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

In previous projects I didn't use text as long as with this project

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019

So the way to solve your problem in the mean time, use a "key" instead of the actual text in your FileUpload description and put the actual text in both languages on the Translate Messages page.

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

A "key"? Sorry, I don't know so much about developing...

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019

Just a brief text that will be different for each photo description. You'll find this text in the "Translate Messages" page where you'll have to populate the actual description in both english and spanish.

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

Ok, I'll do that in the meanwhile. Thanks!

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019

This is not actually a bug as we cannot make the key that much longer anyway, in my opinion. We wouldn't be able to index a "MediumText" MySQL field, so the max length would be 255 anyway.

@munxar what's your take on this?

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

Ok, but then why shorter text are getting duplicated too?

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019

Don't forget that if you make a modification to your description in the FileUpload description, this will create a NEW "key" for the Translate Messages. In this case, you need to delete the previous entry in Translate Messages and update your translations in the NEW one... this is expected behavior.

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

Ok... And there's a way to delete all the messages and import an .csv with all the right messages?

@mjauvin
Copy link
Contributor

mjauvin commented Feb 7, 2019

I am not sure I really understand your question.

@EMAD08
Copy link
Author

EMAD08 commented Feb 7, 2019

I mean, blank the "Translate messages" section and import a clean .csv file that I made with all the messages corrected

@munxar
Copy link
Contributor

munxar commented Feb 7, 2019

@EMAD08 You should be able to export/import the messages, yes. But your problem will persist, as long as you use input fields that a user can change as your 'code' (e.g. photo.description).
You could instead use the files id and prepend some string to generate the description/title or what ever you need.
{{ (photo.id ~ '.description') | translate }}
or
{{ (photo.id ~ '.alt') | translate }}
as long as you don't delete a file, it will have the same key.

@mjauvin we discussed this in another thread regarding import/export and the idea was to use some sort of hashing algorithm for the code. This would reduce the code length to something predictable
and would help to bust the cache of the messages. It would not solve the problem of duplication like described here.
Imho. the message system was build with message keys like 'mysection.mysubsection.title' in mind not to take hole texts from a user input.

@LukeTowers
Copy link
Contributor

User input is really meant to be dealt with using the translatable models

@mjauvin
Copy link
Contributor

mjauvin commented Feb 8, 2019

@LukeTowers there's a PR for the FileUpload that would help here. I think we should push this, even if it would be nice to have the FileUpload revamped as this might take some time.

@mjauvin
Copy link
Contributor

mjauvin commented May 4, 2019

fixed by #470

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

No branches or pull requests

5 participants