Improved notification i18n() replacements.
This commit is contained in:
parent
675a6d1d0c
commit
4a8a167300
4 changed files with 34 additions and 3 deletions
|
@ -1938,6 +1938,7 @@ Translation.create_if_not_exists( :locale => 'de', :source => "to", :target => "
|
||||||
Translation.create_if_not_exists( :locale => 'de', :source => "%s ago", :target => "vor %s" )
|
Translation.create_if_not_exists( :locale => 'de', :source => "%s ago", :target => "vor %s" )
|
||||||
Translation.create_if_not_exists( :locale => 'de', :source => "in %s", :target => "in %s" )
|
Translation.create_if_not_exists( :locale => 'de', :source => "in %s", :target => "in %s" )
|
||||||
Translation.create_if_not_exists( :locale => 'de', :source => "Mark all as seen.", :target => "Alle als gelesen markieren." )
|
Translation.create_if_not_exists( :locale => 'de', :source => "Mark all as seen.", :target => "Alle als gelesen markieren." )
|
||||||
|
Translation.create_if_not_exists( :locale => 'de', :source => "Pending till", :target => "Warten bis" )
|
||||||
#Translation.create_if_not_exists( :locale => 'de', :source => "", :target => "" )
|
#Translation.create_if_not_exists( :locale => 'de', :source => "", :target => "" )
|
||||||
|
|
||||||
# install all packages in auto_install
|
# install all packages in auto_install
|
||||||
|
|
|
@ -80,7 +80,7 @@ module NotificationFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
# translate
|
# translate
|
||||||
data[:string].gsub!( /i18n\((.+?)\)/ ) { |placeholder|
|
data[:string].gsub!( /i18n\((|.+?)\)/ ) { |placeholder|
|
||||||
string = $1
|
string = $1
|
||||||
locale = data[:locale] || 'en'
|
locale = data[:locale] || 'en'
|
||||||
placeholder = Translation.translate( locale, string )
|
placeholder = Translation.translate( locale, string )
|
||||||
|
|
|
@ -126,6 +126,21 @@ class NotificationFactoryTest < ActiveSupport::TestCase
|
||||||
:string => '\#{puts `ls`}',
|
:string => '\#{puts `ls`}',
|
||||||
:result => '\#{puts `ls`} (not allowed)',
|
:result => '\#{puts `ls`} (not allowed)',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
:locale => 'de',
|
||||||
|
:string => 'test i18n(new)',
|
||||||
|
:result => 'test neu',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:locale => 'de',
|
||||||
|
:string => 'test i18n()',
|
||||||
|
:result => 'test ',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
:locale => 'de',
|
||||||
|
:string => 'test i18n(new) i18n(open)',
|
||||||
|
:result => 'test neu offen',
|
||||||
|
},
|
||||||
]
|
]
|
||||||
tests.each { |test|
|
tests.each { |test|
|
||||||
result = NotificationFactory.build(
|
result = NotificationFactory.build(
|
||||||
|
|
|
@ -406,16 +406,21 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
:article_id => article.id,
|
:article_id => article.id,
|
||||||
:type => 'update',
|
:type => 'update',
|
||||||
:changes => {
|
:changes => {
|
||||||
:priority_id => [1, 2],
|
:priority_id => [1, 2],
|
||||||
|
:pending_time => [nil, Time.parse("2015-01-11 23:33:47 UTC")],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
# check changed attributes
|
# check changed attributes
|
||||||
human_changes = bg.human_changes(agent1,ticket1)
|
human_changes = bg.human_changes(agent1,ticket1)
|
||||||
assert( human_changes['Priority'], 'Check if attributes translated based on ObjectManager::Attribute' )
|
assert( human_changes['Priority'], 'Check if attributes translated based on ObjectManager::Attribute' )
|
||||||
|
assert( human_changes['Pending till'], 'Check if attributes translated based on ObjectManager::Attribute' )
|
||||||
assert_equal( 'i18n(1 low)', human_changes['Priority'][0] )
|
assert_equal( 'i18n(1 low)', human_changes['Priority'][0] )
|
||||||
assert_equal( 'i18n(2 normal)', human_changes['Priority'][1] )
|
assert_equal( 'i18n(2 normal)', human_changes['Priority'][1] )
|
||||||
|
assert_equal( 'i18n()', human_changes['Pending till'][0] )
|
||||||
|
assert_equal( 'i18n(2015-01-11 23:33:47 UTC)', human_changes['Pending till'][1] )
|
||||||
assert_not( human_changes['priority_id'] )
|
assert_not( human_changes['priority_id'] )
|
||||||
|
assert_not( human_changes['pending_till'] )
|
||||||
|
|
||||||
# en template
|
# en template
|
||||||
template = bg.template_update(agent2, ticket1, article, human_changes)
|
template = bg.template_update(agent2, ticket1, article, human_changes)
|
||||||
|
@ -424,6 +429,8 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
assert_match( /Priority/, template[:body] )
|
assert_match( /Priority/, template[:body] )
|
||||||
assert_match( /1 low/, template[:body] )
|
assert_match( /1 low/, template[:body] )
|
||||||
assert_match( /2 normal/, template[:body] )
|
assert_match( /2 normal/, template[:body] )
|
||||||
|
assert_match( /Pending till/, template[:body] )
|
||||||
|
assert_match( /2015-01-11 23:33:47 UTC/, template[:body] )
|
||||||
assert_match( /updated/i, template[:subject] )
|
assert_match( /updated/i, template[:subject] )
|
||||||
|
|
||||||
# en notification
|
# en notification
|
||||||
|
@ -449,7 +456,10 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
assert_match( /Priority/, body )
|
assert_match( /Priority/, body )
|
||||||
assert_match( /1 low/, body )
|
assert_match( /1 low/, body )
|
||||||
assert_match( /2 normal/, body )
|
assert_match( /2 normal/, body )
|
||||||
|
assert_match( /Pending till/, body )
|
||||||
|
assert_match( /2015-01-11 23:33:47 UTC/, body )
|
||||||
assert_match( /update/, body )
|
assert_match( /update/, body )
|
||||||
|
assert_no_match( /i18n/, body )
|
||||||
|
|
||||||
# de template
|
# de template
|
||||||
template = bg.template_update(agent1, ticket1, article, human_changes)
|
template = bg.template_update(agent1, ticket1, article, human_changes)
|
||||||
|
@ -458,6 +468,8 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
assert_match( /Priority/, template[:body] )
|
assert_match( /Priority/, template[:body] )
|
||||||
assert_match( /1 low/, template[:body] )
|
assert_match( /1 low/, template[:body] )
|
||||||
assert_match( /2 normal/, template[:body] )
|
assert_match( /2 normal/, template[:body] )
|
||||||
|
assert_match( /Pending till/, template[:body] )
|
||||||
|
assert_match( /2015-01-11 23:33:47 UTC/, template[:body] )
|
||||||
assert_match( /aktualis/, template[:subject] )
|
assert_match( /aktualis/, template[:subject] )
|
||||||
|
|
||||||
# de notification
|
# de notification
|
||||||
|
@ -484,7 +496,10 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
assert_match( /Priorität/, body )
|
assert_match( /Priorität/, body )
|
||||||
assert_match( /1 niedrig/, body )
|
assert_match( /1 niedrig/, body )
|
||||||
assert_match( /2 normal/, body )
|
assert_match( /2 normal/, body )
|
||||||
|
assert_match( /Warten/, body )
|
||||||
|
assert_match( /2015-01-11 23:33:47 UTC/, body )
|
||||||
assert_match( /aktualis/, body )
|
assert_match( /aktualis/, body )
|
||||||
|
assert_no_match( /i18n/, body )
|
||||||
|
|
||||||
bg = Observer::Ticket::Notification::BackgroundJob.new(
|
bg = Observer::Ticket::Notification::BackgroundJob.new(
|
||||||
:ticket_id => ticket1.id,
|
:ticket_id => ticket1.id,
|
||||||
|
@ -500,7 +515,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
puts "hc #{human_changes.inspect}"
|
puts "hc #{human_changes.inspect}"
|
||||||
|
|
||||||
|
|
||||||
human_changes = bg.human_changes(agent2,ticket1)
|
human_changes = bg.human_changes(agent2,ticket1)
|
||||||
puts "hc2 #{human_changes.inspect}"
|
puts "hc2 #{human_changes.inspect}"
|
||||||
|
|
||||||
template = bg.template_update(agent1, ticket1, article, human_changes)
|
template = bg.template_update(agent1, ticket1, article, human_changes)
|
||||||
|
|
Loading…
Reference in a new issue