Browse Source

Fixes #5139 - Unable to send WhatsApp automatic reminders after 23 hours.

Co-authored-by: Tobias Schäfer <ts@zammad.com>
Florian Liebe 10 months ago
parent
commit
d62b0f50a5
2 changed files with 12 additions and 1 deletions
  1. 1 1
      app/models/translation.rb
  2. 11 0
      spec/models/translation_spec.rb

+ 1 - 1
app/models/translation.rb

@@ -77,7 +77,7 @@ translate strings in Ruby context, e. g. for notifications
 =end
 
   def self.translate(locale, string, *args)
-    translated = find_source(locale, string)&.target || string
+    translated = find_source(locale, string)&.target.presence || string
 
     translated %= args if args.any?
 

+ 11 - 0
spec/models/translation_spec.rb

@@ -36,6 +36,17 @@ RSpec.describe Translation do
     end
   end
 
+  context 'default string translations with fallback' do
+    before do
+      create(:translation, locale: 'de-de', source: 'dummy message', target: '', target_initial: '')
+      described_class.sync_locale_from_po('de-de')
+    end
+
+    it 'fallbacks to provided message/string when de-de is empty' do
+      expect(described_class.translate('de-de', 'dummy message')).to eq('dummy message')
+    end
+  end
+
   context 'when using find_source' do
     it 'de-de with existing title case word' do
       expect(described_class.find_source('de-de', 'New')).to have_attributes(source: 'New', target_initial: 'Neu', target: 'Neu')