-
Notifications
You must be signed in to change notification settings - Fork 52
FEATURE: Translate categories and tags #269
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
base: main
Are you sure you want to change the base?
Conversation
422a3ed
to
0e8c3e2
Compare
AND m.user_id > 0 | ||
#{max_age_clause} | ||
WHERE m.#{content_column} != '' | ||
#{not_deleted_clause(model)} |
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.
Unlike posts and topics, categories and tags do not have a deleted_at
nor can be created by a bot
[ | ||
[Topic, "title"], | ||
[Post, "raw"], | ||
[Category, "name"], |
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.
There is Category#description
too. Is that something we want to consider in this PR too?
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.
Not yet. Category descriptions are currently topics so we will ignore for now.
#{not_deleted_clause(model)} | ||
#{non_bot_clause(model)} | ||
#{max_age_clause(model)} |
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.
I'm wondering if it makes sense to just make this backfill_clause(model)
or something instead of having the logic of model == Post || model == Topic
present over 3 methods. This also makes the complete query much easier to read/understand IMO instead of having 3 parts to combine mentally.
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.
Actually the current query looks very neat instead of having to repeat the clause for every model
SELECT m.id
FROM #{model.table_name} m
#{limit_to_public_clause(model)}
WHERE m.#{content_column} != ''
#{not_deleted_clause(model)}
#{non_bot_clause(model)}
#{max_age_clause(model)}
ORDER BY m.updated_at DESC
I will prefer optimizing next time if it gets more complex.
# frozen_string_literal: true | ||
|
||
module DiscourseTranslator | ||
class CategoryTranslation < ActiveRecord::Base |
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.
Do we need to differentiate between Category#name
and Category#description
? It might be useful to think about how we can expand this table to store the translation for more than a single column since some models may have multiple columns that requires us to translate.
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.
No.
This current implementation makes use of the translatable
concern. Category descriptions point to a topic so it will use topic translations instead.
Adding categories and tags into the fray.
This PR only adds translations for the categories and tags, without displaying them yet. That will come in a separate PR as we figure out caching and appropriate APIs in core.