Browse Source

Fixes: #5067 - Notifications do not translate a string

Martin Gruner 11 months ago
parent
commit
8be32eff2a

+ 1 - 1
app/models/translation/synchronizes_from_po.rb

@@ -23,7 +23,7 @@ module Translation::SynchronizesFromPo
         # Ignore strings that come only from the chat, form and view_template extractors.
         # We tried avoiding this by using gettext flags in the pot file, but they don't propagate
         #   correctly to the translation files.
-        ref.to_s.start_with?(%r{public/assets/(?:chat|form)/|app/views/(?:mailer|messaging)/})
+        ref.to_s.start_with?(%r{public/assets/(?:chat|form)/|app/views/(?:mailer|messaging)/[^/]+/})
       end
       new(source: source, translation: translation, translation_file: file, skip_sync: skip_sync)
     end

+ 26 - 1
spec/lib/notification_factory/mailer_spec.rb

@@ -5,6 +5,31 @@ require 'ostruct'
 
 RSpec.describe NotificationFactory::Mailer do
   describe '#template' do
+
+    context 'with application template' do
+      let(:result) { described_class.template(template: 'test_ticket', locale: locale, objects: {}) }
+
+      context 'with English locale' do
+        let(:locale) { 'en' }
+
+        it 'renders correctly' do
+          expect(result[:subject]).to eq('Test Ticket!')
+          expect(result[:body]).to include('Your Zammad Helpdesk Team')
+          expect(result[:body]).to include('Manage your notification settings')
+        end
+      end
+
+      context 'with German locale' do
+        let(:locale) { 'de-de' }
+
+        it 'renders correctly' do
+          expect(result[:subject]).to eq('Test Ticket!')
+          expect(result[:body]).to include('Ihr Zammad Helpdesk-Team')
+          expect(result[:body]).to include('Benachrichtigungs-Einstellungen verwalten')
+        end
+      end
+    end
+
     context 'for postmaster oversized mail' do
       let(:raw_incoming_mail) { Rails.root.join('test/data/mail/mail010.box').read }
 
@@ -55,7 +80,7 @@ RSpec.describe NotificationFactory::Mailer do
 
       context 'English locale (en)' do
         include_examples 'plaintext mail templating' do
-          let(:locale) { 'en' }
+          let(:locale)           { 'en' }
           let(:expected_subject) { en_expected_subject }
           let(:expected_body)    { en_expected_body }
         end