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

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

Conversation

szeroual
Copy link

@szeroual szeroual commented Aug 9, 2023

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:
- messages.fr_FR.yml
domain: messages
locale: fr_FR
extention: yml
- messages+intl-icu.fr_FR.yml
domain: messages+intl-icu
locale: fr_FR
extention: yml
as a consequence the translation for the two files is imported twice
AttachFileHandler (1)
if we delete the keys andnupdate the domaines for both files, in order to have the same domain for both of them, the import command will create one translation key, but the old one (first i serted in the DB) is the one saved as a translation for the key
AttachFileHandler (2)

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
Copy link
Collaborator

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

@bartmcleod
Copy link
Collaborator

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

@szeroual szeroual force-pushed the s392/featue/31918-display-translation-keys-without-duplicates-in-the-translation-key branch from a13ee37 to 27819e7 Compare August 9, 2023 14:20
@bartmcleod
Copy link
Collaborator

@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 bartmcleod closed this Aug 9, 2023
@bartmcleod
Copy link
Collaborator

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
Copy link
Collaborator

re-open

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

Successfully merging this pull request may close these issues.

None yet

4 participants