Translate-plugin: Duplicated messages

Created on 6 Feb 2019  Â·  34Comments  Â·  Source: rainlab/translate-plugin

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

Completed Bug

Most helpful comment

@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.

All 34 comments

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?

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

can you send a screenshot of the place where the original text comes from?

--
Marc

On Thu, Feb 7, 2019, 10:10 Emiliano Mina <[email protected] wrote:

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.

[image: translate-duplicated]
https://user-images.githubusercontent.com/25836873/52420716-3864f400-2ab8-11e9-95f0-01eb45dfb83a.jpg

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/rainlab/translate-plugin/issues/443#issuecomment-461460817,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB65vv2emd9MraBG0ve436F-F_TwQGkXks5vLEHzgaJpZM4amK3p
.

Here it is
alt-text

Is that for a FileUpload or MediaFinder?

On Thu, Feb 7, 2019 at 10:55 AM Emiliano Mina notifications@github.com
wrote:

Here it is
[image: alt-text]
https://user-images.githubusercontent.com/25836873/52423810-736a2600-2abe-11e9-9630-1ddf9272d542.jpg

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/rainlab/translate-plugin/issues/443#issuecomment-461482533,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB65vr39y-8k4-sWu6T79TI_wU-Gap4tks5vLExggaJpZM4amK3p
.

--
Marc

FileUpload

It's odd because you get the same behavior as if you were using a
translated field in 3 languages but you're not.

How many languages do you have for this website?

On Thu, Feb 7, 2019 at 10:57 AM Emiliano Mina notifications@github.com
wrote:

FileUpload

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/rainlab/translate-plugin/issues/443#issuecomment-461483787,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB65vjLgY231ikAraeRsIs8jYrzhvz7Vks5vLEz-gaJpZM4amK3p
.

--
Marc

I'm using 2, English and Spanish.

I'll try to reproduce this.

On Thu, Feb 7, 2019 at 11:08 AM Emiliano Mina notifications@github.com
wrote:

I'm using 2, English and Spanish.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/rainlab/translate-plugin/issues/443#issuecomment-461488976,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB65vri0iYxTId6FZQ7Uuvw5GdZI5dezks5vLE-KgaJpZM4amK3p
.

--
Marc

Ok, thank you very much!

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?

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

I could not reproduce this behavior. Maybe @munxar has something here with
the key length.

Can you send a text version of one of the text exhibiting this behavior so
I can try with the same value?

On Thu, Feb 7, 2019 at 11:12 AM munxar notifications@github.com wrote:

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

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/rainlab/translate-plugin/issues/443#issuecomment-461490853,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB65vrthrqS9fp4EPkPvHLvbm_PP7sazks5vLFBwgaJpZM4amK3p
.

--
Marc

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

@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

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

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

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

@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?

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

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.

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

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.

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

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?

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

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.

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

I am not sure I really understand your question.

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

@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.

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

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tobias-kuendig picture tobias-kuendig  Â·  7Comments

ref picture ref  Â·  4Comments

patrick-durrer picture patrick-durrer  Â·  7Comments

Eoler picture Eoler  Â·  7Comments

Ladylain picture Ladylain  Â·  3Comments