discourse-translator/app/models/discourse_translator/post_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
798 B
Ruby

# frozen_string_literal: true
module DiscourseTranslator
class PostTranslation < ActiveRecord::Base
self.table_name = "discourse_translator_post_translations"
belongs_to :post
validates :post_id, presence: true
validates :locale, presence: true
validates :translation, presence: true
validates :locale, uniqueness: { scope: :post_id }
end
end
# == Schema Information
#
# Table name: discourse_translator_post_translations
#
# id :bigint not null, primary key
# post_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_post_id_locale_0cc3d81e5b (post_id,locale) UNIQUE
#