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

Missing phrases after import #111

Open
LorensoD opened this issue May 7, 2024 · 0 comments
Open

Missing phrases after import #111

LorensoD opened this issue May 7, 2024 · 0 comments

Comments

@LorensoD
Copy link

LorensoD commented May 7, 2024

I've identified a potential issue in the ImportTranslationsCommand, specifically within the syncMissingTranslations() function. The function is designed to create a new phrase in the specified locale if it doesn't already exist, but only if it exists in the source locale. However, the current implementation may not correctly handle phrases across different translation files.

Current Implementation:

The existing code checks if a phrase with the same key exists in the specified locale, but it doesn't consider the translation group (file) the phrase belongs to. The relevant code is on line 130:

if (! $translation->phrases()->where('key', $phrase->key)->first()) {

Issue:

This approach can lead to inaccuracies where phrases from different groups might get conflated if they share the same key. This was apparent after some phrases were missing in my non-source languages when importing translation strings.

Proposed Change:

To address this issue, I suggest modifying the check to include the translation group. This ensures the uniqueness of phrases is respected not just by key but also by the group they belong to. The code would then look like this:

if (! $translation->phrases()->where('group', $phrase->group)->where('key', $phrase->key)->first()) {

Additional Note:

This adjustment should also be mirrored in the SyncPhrasesAction:52.

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

1 participant