-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Improve remote translations #3917
Improve remote translations #3917
Conversation
d6b751c
to
36b70c3
Compare
2942caf
to
910cad8
Compare
3365836
to
2b99a00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't mind, I'll be doing the review in two parts 🤣.
Part one (this review) deals with everything except rack-attack.
Part two (coming soon?) will deal with rack-attack.
To be continued...
app/models/remote_translation.rb
Outdated
|
||
def already_translated_resource | ||
if remote_translatable&.translations&.where(locale: locale).present? | ||
errors.add(:locale, I18n.t("remote_translations.already_translated_resource")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about errors.add(:locale, :already_translated)
? We could then configure it like we configure other translation messages, adding translations to activerecord.yml
. I think the translation key would be something like activerecord.errors.models.remote_translation.attributes.locale.already_translated
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solved in the commit: cdb2937
a747c92
to
bdbc924
Compare
bdbc924
to
6584eb1
Compare
- Do not display remote translations button when API key is not configured
6584eb1
to
2d56653
Compare
it "When defined in current locale should not detect remote_translations" do | ||
proposal = create(:proposal) | ||
comment = create(:comment, commentable: proposal) | ||
|
||
expect(detect_remote_translations([proposal, comment])).to eq [] | ||
end | ||
|
||
it "When resource class has not translates should not detect remote_translations" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"has not translates" seems to be a typo 🤔. How about "is not translatable"?
aa50512
to
807a55d
Compare
- Validate that locale is a valid locale for RemoteTranslation Client. - RemoteTranslation can only be created for resources that do not have the requested language translated
Legislation::Proposal is not Globalize model but use CommentableActions and try detect remote translations. Add new condition to discard Non Globalize models. This fix is necessary since the following commit was included: c1f3a4a.
807a55d
to
c5c771f
Compare
…e-translations Improve remote translations
References
Related PR's:
Objectives
Visual Changes
None
Notes
None