File tree 2 files changed +7
-1
lines changed
app/services/discourse_translator
2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change 3
3
module DiscourseTranslator
4
4
class PostTranslator
5
5
def self . translate ( post , target_locale = I18n . locale )
6
- return if post . blank? || target_locale . blank?
6
+ return if post . blank? || target_locale . blank? || post . locale == target_locale . to_s
7
7
8
8
target_locale_sym = target_locale . to_s . sub ( "-" , "_" ) . to_sym
9
9
Original file line number Diff line number Diff line change 22
22
expect ( described_class . translate ( post , "" ) ) . to eq ( nil )
23
23
end
24
24
25
+ it "returns nil if target_locale is same as post locale" do
26
+ post . locale = "en"
27
+
28
+ expect ( described_class . translate ( post , "en" ) ) . to eq ( nil )
29
+ end
30
+
25
31
it "translates with post and locale" do
26
32
translator . expects ( :translate_post! ) . with ( post , :ja ) . returns ( translated_raw )
27
33
You can’t perform that action at this time.
0 commit comments