Skip to content

Conversation

@nattsw
Copy link
Contributor

@nattsw nattsw commented Feb 17, 2025

In the older implementation of translation, there exists these two site settings are part of the criteria that determines if 🌐 shows up per post

  • restrict translation by group - Only allowed groups can translate
  • restrict translation by poster group - Only allow translation of posts made by users in allowed groups. If empty, allow translations of posts from all users.

In a recent update with experimental features, we updated the cases where 🌐 will show up and caused a regression where the 🌐 shows up for everyone in restrict translation by group, ignoring restrict translation by poster group.

This PR makes sure these two site settings are adhered to when the experimental topic setting is turned off.

expect(guardian.can_translate?(post)).to eq(true)
end

it "can translate when post does not have translation" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setup for this test is exactly the same as the test before it. I think the set up for this test should be clearing out the post's translation?

Copy link
Contributor Author

@nattsw nattsw Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The post will not have translation if I don't explicitly add post.set_translation(locale, text)

It's exactly the same setup, but my intent is that the test description is the documentation of the behaviour not the implementation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for clarifying 👍 Perhaps we can just combine the two test cases into one? Technically we can only translate when post's detected locale does not match i18n locale and also when the post does not have translation.

Might also be useful to assert that the post cannot be translated when the post's translation is present for the given locale.

Copy link
Contributor Author

@nattsw nattsw Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the post cannot be translated when the post's translation is present for the given locale

Actually, "can_translate" is the bool that determines if the 🌐 appears on the post.

(Old feature) If the translation exists for the locale, the value should still be true, since the user will click on 🌐 and we will return the existing translation to the user. This is the old feature that we need to maintain, where viewing translations are manual, not the new feature where it is automatically rendered by default.

old feature

Screenshot 2025-02-18 at 2 44 32 PM

new experimental feature

Screenshot 2025-02-18 at 2 47 33 PM

@nattsw nattsw merged commit cdb3a59 into main Feb 18, 2025
5 checks passed
@nattsw nattsw deleted the hide-globe branch February 18, 2025 07:09
return false if post.translation_for(I18n.locale).present?
true
else
return false if post.locale_matches?(I18n.locale)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small one but this check is the same regardless of the conditional so we can technically pull this out of the conditional.

nattsw added a commit that referenced this pull request Feb 26, 2025
This is a refactor to prepare for a fix, so that the fix PR is less messy. Related comment here: #215 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants