lexik / LexikTranslationBundle

This Symfony bundle allow to import translation files content into the database and provide a GUI to edit translations.
MIT License
419 stars 255 forks source link

S392/featue/31918 display translation keys without duplicates in the translation key #439

Closed szeroual closed 11 months ago

szeroual commented 11 months ago

When the updated translations file messages+intl-icu.en_GB.yml is used in the translation tool and we run the app/console lexik:translations:import command we can see that in the translation tool UI we have duplicate values for the same translation key (old and updated one) as can be seen in the screenshot bellow: MicrosoftTeams-image (2) It's because the translation file has the s+intl-icu suffix compared to the old file name and is treated as a new file in the translation tool DB

For the import commande, each file is identified by the triplet: domain, locale, extention for exemple:

what to do:

  1. update the commande to delete all keys in the case of messages+intl-icu files
  2. if there is more then one file identified by same locale ans prefexed by messages, force the update (import file parameter $forceUpdate=true)
  3. Make messages and messagesxxxx have same domaine (messages)

what is left to do: update the commande to delete all keys in the case of messages+intl-icu files

bartmcleod commented 11 months ago

@szeroual Can you explain how the title of the PR relates to the code changes? I don't understand...

bartmcleod commented 11 months ago

@elghailani can you explain what the logic is trying to do? in relation to the title of this PR?

bartmcleod commented 11 months ago

@szeroual thanks for the explanation and reproduction steps. I do not think checking strpos ! false is correct in this case. substr starting from 0 index could work, or even strpos === 0 to ensure the domain at least starts with 'messages'. Still, what if someone creates a domain that also starts with 'messages', such as 'messages-for-beginners'?

bartmcleod commented 11 months ago

I don't remember how or why I clossed this, so I re-open it. I think this feature could be done, just differently, by configuring for which keys you would like to merge domains in which order.

bartmcleod commented 11 months ago

re-open