discourse-translator/app/models/discourse_translator/topic_translation.rb
Natalie Tay 00a202feb6
FIX: 'Show original' button only shows in topics where there are translated content (#240)
Currently, the button above shows up even when there are no posts translated. With this commit, we will not show the button if there are zero posts in the topic that is translated.

This commit also
- only returns translations of supported languages (in SiteSetting.automatic_translation_target_languages)
- optimises loading translations when the feature is enabled under certain circumstances
2025-03-06 11:36:44 +08:00

30 lines
806 B
Ruby

# frozen_string_literal: true
module DiscourseTranslator
class TopicTranslation < ActiveRecord::Base
self.table_name = "discourse_translator_topic_translations"
belongs_to :topic
validates :topic_id, presence: true
validates :locale, presence: true
validates :translation, presence: true
validates :locale, uniqueness: { scope: :topic_id }
end
end
# == Schema Information
#
# Table name: discourse_translator_topic_translations
#
# id :bigint not null, primary key
# topic_id :integer not null
# locale :string not null
# translation :text not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# idx_on_topic_id_locale_70b2f83213 (topic_id,locale) UNIQUE
#