Merge branch 'develop' of github.com:martini/zammad into develop
This commit is contained in:
commit
b6277759dd
6 changed files with 91 additions and 123 deletions
|
@ -401,7 +401,7 @@ class chatWindow extends App.Controller
|
||||||
timestamp = Date.now()
|
timestamp = Date.now()
|
||||||
|
|
||||||
if !@lastTimestamp or timestamp - @lastTimestamp > @showTimeEveryXMinutes * 60000
|
if !@lastTimestamp or timestamp - @lastTimestamp > @showTimeEveryXMinutes * 60000
|
||||||
label = 'Today'
|
label = App.i18n.translateContent('today')
|
||||||
time = new Date().toTimeString().substr(0,5)
|
time = new Date().toTimeString().substr(0,5)
|
||||||
if @lastAddedType is 'timestamp'
|
if @lastAddedType is 'timestamp'
|
||||||
# update last time
|
# update last time
|
||||||
|
|
|
@ -152,6 +152,13 @@ class Navbar extends App.Controller
|
||||||
render: (data) =>
|
render: (data) =>
|
||||||
return if !data
|
return if !data
|
||||||
|
|
||||||
|
# do not show vertical navigation if only one tab exists
|
||||||
|
if @vertical
|
||||||
|
if data && data.length <= 1
|
||||||
|
@el.addClass('hidden')
|
||||||
|
else
|
||||||
|
@el.removeClass('hidden')
|
||||||
|
|
||||||
# set page title
|
# set page title
|
||||||
if @activeState && @view && !@vertical
|
if @activeState && @view && !@vertical
|
||||||
for item in data
|
for item in data
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Index extends App.ControllerContent
|
||||||
@locale = App.i18n.get()
|
@locale = App.i18n.get()
|
||||||
@render()
|
@render()
|
||||||
@bind(
|
@bind(
|
||||||
'i18n:translation_update',
|
'i18n:translation_update_todo i18n:translation_update_list i18n:translation_update',
|
||||||
=>
|
=>
|
||||||
@load()
|
@load()
|
||||||
)
|
)
|
||||||
|
@ -59,6 +59,8 @@ class Index extends App.ControllerContent
|
||||||
@translationToDo = new TranslationToDo(
|
@translationToDo = new TranslationToDo(
|
||||||
el: @$('.js-ToDo')
|
el: @$('.js-ToDo')
|
||||||
locale: @locale
|
locale: @locale
|
||||||
|
updateOnServer: @updateOnServer
|
||||||
|
getAttributes: @getAttributes
|
||||||
)
|
)
|
||||||
@translationToDo.update(
|
@translationToDo.update(
|
||||||
stringsNotTranslated: @stringsNotTranslated
|
stringsNotTranslated: @stringsNotTranslated
|
||||||
|
@ -69,6 +71,8 @@ class Index extends App.ControllerContent
|
||||||
@translationList = new TranslationList(
|
@translationList = new TranslationList(
|
||||||
el: @$('.js-List')
|
el: @$('.js-List')
|
||||||
locale: @locale
|
locale: @locale
|
||||||
|
updateOnServer: @updateOnServer
|
||||||
|
getAttributes: @getAttributes
|
||||||
)
|
)
|
||||||
@translationList.update(
|
@translationList.update(
|
||||||
stringsNotTranslated: @stringsNotTranslated
|
stringsNotTranslated: @stringsNotTranslated
|
||||||
|
@ -86,7 +90,6 @@ class Index extends App.ControllerContent
|
||||||
console.log('rr')
|
console.log('rr')
|
||||||
if @translationList.changes()
|
if @translationList.changes()
|
||||||
App.Delay.set(rerender, 400)
|
App.Delay.set(rerender, 400)
|
||||||
console.log('111', @translationList.changes())
|
|
||||||
|
|
||||||
hideAction: =>
|
hideAction: =>
|
||||||
@el.closest('.content').find('.js-changes').addClass('hidden')
|
@el.closest('.content').find('.js-changes').addClass('hidden')
|
||||||
|
@ -97,7 +100,6 @@ class Index extends App.ControllerContent
|
||||||
message: 'Pushing translations to i18n.zammad.com'
|
message: 'Pushing translations to i18n.zammad.com'
|
||||||
container: @el.closest('.content')
|
container: @el.closest('.content')
|
||||||
)
|
)
|
||||||
|
|
||||||
@ajax(
|
@ajax(
|
||||||
id: 'translations'
|
id: 'translations'
|
||||||
type: 'PUT'
|
type: 'PUT'
|
||||||
|
@ -118,7 +120,6 @@ class Index extends App.ControllerContent
|
||||||
message: 'Reseting changes...'
|
message: 'Reseting changes...'
|
||||||
container: @el.closest('.content')
|
container: @el.closest('.content')
|
||||||
)
|
)
|
||||||
|
|
||||||
@ajax(
|
@ajax(
|
||||||
id: 'translations'
|
id: 'translations'
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
|
@ -139,7 +140,6 @@ class Index extends App.ControllerContent
|
||||||
message: 'Getting latest translations from i18n.zammad.com'
|
message: 'Getting latest translations from i18n.zammad.com'
|
||||||
container: @el.closest('.content')
|
container: @el.closest('.content')
|
||||||
)
|
)
|
||||||
|
|
||||||
hide = =>
|
hide = =>
|
||||||
App.Event.trigger('i18n:translation_update')
|
App.Event.trigger('i18n:translation_update')
|
||||||
@hideAction()
|
@hideAction()
|
||||||
|
@ -164,6 +164,44 @@ class Index extends App.ControllerContent
|
||||||
@_syncChanges(locale, locales, loader, hide)
|
@_syncChanges(locale, locales, loader, hide)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
updateOnServer: (params, event) =>
|
||||||
|
|
||||||
|
# update runtime if same language is used
|
||||||
|
if App.i18n.get() is params.locale
|
||||||
|
App.i18n.setMap(params.source, params.target, params.format)
|
||||||
|
|
||||||
|
# remove not needed attributes
|
||||||
|
delete params.field
|
||||||
|
|
||||||
|
if params.id
|
||||||
|
method = 'PUT'
|
||||||
|
url = "#{@apiPath}/translations/#{params.id}"
|
||||||
|
else
|
||||||
|
method = 'POST'
|
||||||
|
url = "#{@apiPath}/translations"
|
||||||
|
|
||||||
|
@ajax(
|
||||||
|
id: 'translations'
|
||||||
|
type: method
|
||||||
|
url: url
|
||||||
|
data: JSON.stringify(params)
|
||||||
|
processData: false
|
||||||
|
success: (data, status, xhr) ->
|
||||||
|
if event
|
||||||
|
App.Event.trigger(event)
|
||||||
|
)
|
||||||
|
|
||||||
|
getAttributes: (e) =>
|
||||||
|
field = $(e.target).closest('tr').find('.js-Item')
|
||||||
|
params =
|
||||||
|
id: field.data('id')
|
||||||
|
source: field.data('source')
|
||||||
|
format: field.data('format') || 'string'
|
||||||
|
initial: field.data('initial') || ''
|
||||||
|
target: field.val()
|
||||||
|
locale: @locale
|
||||||
|
field: field
|
||||||
|
|
||||||
class TranslationToDo extends App.Controller
|
class TranslationToDo extends App.Controller
|
||||||
events:
|
events:
|
||||||
'click .js-create': 'create'
|
'click .js-create': 'create'
|
||||||
|
@ -187,8 +225,14 @@ class TranslationToDo extends App.Controller
|
||||||
@html ''
|
@html ''
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# add not translated items from runtime
|
||||||
if App.i18n.getNotTranslated(@locale)
|
if App.i18n.getNotTranslated(@locale)
|
||||||
for key, value of App.i18n.getNotTranslated(@locale)
|
for key, value of App.i18n.getNotTranslated(@locale)
|
||||||
|
found = false
|
||||||
|
for notTranslatedItem in @stringsNotTranslated
|
||||||
|
if key is notTranslatedItem[1]
|
||||||
|
found = true
|
||||||
|
if !found
|
||||||
item = [ '', key, '', '']
|
item = [ '', key, '', '']
|
||||||
@stringsNotTranslated.push item
|
@stringsNotTranslated.push item
|
||||||
|
|
||||||
|
@ -198,80 +242,34 @@ class TranslationToDo extends App.Controller
|
||||||
|
|
||||||
create: (e) =>
|
create: (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
field = $(e.target).closest('tr').find('.js-Item')
|
params = @getAttributes(e)
|
||||||
id = field.data('id')
|
return if !params.target
|
||||||
source = field.data('source')
|
|
||||||
format = 'string'
|
|
||||||
target = field.val()
|
|
||||||
return if !target
|
|
||||||
|
|
||||||
# remove from not translated list
|
# remove from not translated list
|
||||||
$(e.target).closest('tr').remove()
|
$(e.target).closest('tr').remove()
|
||||||
|
|
||||||
# local update
|
# local update
|
||||||
App.i18n.removeNotTranslated(@locale, source)
|
App.i18n.removeNotTranslated(params.locale, params.source)
|
||||||
|
|
||||||
# update runtime if same language is used
|
|
||||||
if App.i18n.get() is @locale
|
|
||||||
App.i18n.setMap(source, target, 'string')
|
|
||||||
|
|
||||||
# remote update
|
# remote update
|
||||||
params =
|
params.target_initial = ''
|
||||||
locale: @locale
|
@updateOnServer(params, 'i18n:translation_update_list')
|
||||||
source: source
|
|
||||||
target: target
|
|
||||||
target_initial: ''
|
|
||||||
|
|
||||||
if id
|
|
||||||
method = 'PUT'
|
|
||||||
params.id = id
|
|
||||||
url = "#{@apiPath}/translations/#{id}"
|
|
||||||
else
|
|
||||||
method = 'POST'
|
|
||||||
url = "#{@apiPath}/translations"
|
|
||||||
|
|
||||||
@ajax(
|
|
||||||
id: 'translations'
|
|
||||||
type: method
|
|
||||||
url: url
|
|
||||||
data: JSON.stringify(params)
|
|
||||||
processData: false
|
|
||||||
success: (data, status, xhr) ->
|
|
||||||
App.Event.trigger('i18n:translation_update')
|
|
||||||
)
|
|
||||||
|
|
||||||
same: (e) =>
|
same: (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@hasChanges = true
|
@hasChanges = true
|
||||||
field = $(e.target).closest('tr').find('.js-Item')
|
params = @getAttributes(e)
|
||||||
source = field.data('source')
|
|
||||||
|
|
||||||
# remove from not translated list
|
# remove from not translated list
|
||||||
$(e.target).closest('tr').remove()
|
$(e.target).closest('tr').remove()
|
||||||
|
|
||||||
# local update
|
# local update
|
||||||
App.i18n.removeNotTranslated(@locale, source)
|
App.i18n.removeNotTranslated(params.locale, params.source)
|
||||||
|
|
||||||
# update runtime if same language is used
|
|
||||||
if App.i18n.get() is @locale
|
|
||||||
App.i18n.setMap(source, source, 'string')
|
|
||||||
|
|
||||||
# remote update
|
# remote update
|
||||||
params =
|
params.target_initial = ''
|
||||||
locale: @locale
|
params.target = params.source
|
||||||
source: source
|
@updateOnServer(params, 'i18n:translation_update_list')
|
||||||
target: source
|
|
||||||
target_initial: ''
|
|
||||||
|
|
||||||
@ajax(
|
|
||||||
id: 'translations'
|
|
||||||
type: 'POST'
|
|
||||||
url: @apiPath + '/translations'
|
|
||||||
data: JSON.stringify(params)
|
|
||||||
processData: false
|
|
||||||
success: (data, status, xhr) ->
|
|
||||||
App.Event.trigger('i18n:translation_update')
|
|
||||||
)
|
|
||||||
|
|
||||||
class TranslationList extends App.Controller
|
class TranslationList extends App.Controller
|
||||||
hasChanges: false
|
hasChanges: false
|
||||||
|
@ -288,6 +286,7 @@ class TranslationList extends App.Controller
|
||||||
@render()
|
@render()
|
||||||
|
|
||||||
render: =>
|
render: =>
|
||||||
|
return if _.isEmpty(@stringsTranslated)
|
||||||
@html App.view('translation/list')(
|
@html App.view('translation/list')(
|
||||||
times: @times
|
times: @times
|
||||||
strings: @stringsTranslated
|
strings: @stringsTranslated
|
||||||
|
@ -299,66 +298,23 @@ class TranslationList extends App.Controller
|
||||||
resetItem: (e) ->
|
resetItem: (e) ->
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@hasChanges = true
|
@hasChanges = true
|
||||||
field = $(e.target).closest('tr').find('.js-Item')
|
params = @getAttributes(e)
|
||||||
id = field.data('id')
|
|
||||||
source = field.data('source')
|
|
||||||
initial = field.data('initial')
|
|
||||||
format = field.data('format')
|
|
||||||
|
|
||||||
# update runtime if same language is used
|
|
||||||
if App.i18n.get() is @locale
|
|
||||||
App.i18n.setMap(source, initial, format)
|
|
||||||
|
|
||||||
# locale reset
|
|
||||||
field.val(initial)
|
|
||||||
@updateRow(id)
|
|
||||||
|
|
||||||
# remote reset
|
# remote reset
|
||||||
params =
|
params.target = params.initial
|
||||||
id: id
|
@updateOnServer(params, 'i18n:translation_update')
|
||||||
target: initial
|
|
||||||
|
|
||||||
@ajax(
|
|
||||||
id: 'translations'
|
|
||||||
type: 'PUT'
|
|
||||||
url: "#{@apiPath}/translations/#{id}"
|
|
||||||
data: JSON.stringify(params)
|
|
||||||
processData: false
|
|
||||||
success: (data, status, xhr) ->
|
|
||||||
App.Event.trigger('i18n:translation_update')
|
|
||||||
)
|
|
||||||
|
|
||||||
updateItem: (e) ->
|
updateItem: (e) ->
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@hasChanges = true
|
@hasChanges = true
|
||||||
field = $(e.target).closest('tr').find('.js-Item')
|
params = @getAttributes(e)
|
||||||
id = field.data('id')
|
return if !params.target
|
||||||
source = field.data('source')
|
|
||||||
format = field.data('format')
|
|
||||||
target = field.val()
|
|
||||||
return if !target
|
|
||||||
|
|
||||||
# local update
|
# local update
|
||||||
@updateRow(id)
|
@updateRow(params.id)
|
||||||
|
|
||||||
# update runtime if same language is used
|
|
||||||
if App.i18n.get() is @locale
|
|
||||||
App.i18n.setMap(source, target, format)
|
|
||||||
|
|
||||||
# remote update
|
# remote update
|
||||||
params =
|
@updateOnServer(params)
|
||||||
id: id
|
|
||||||
target: target
|
|
||||||
|
|
||||||
@ajax(
|
|
||||||
id: 'translations'
|
|
||||||
type: 'PUT'
|
|
||||||
url: "#{@apiPath}/translations/#{id}"
|
|
||||||
data: JSON.stringify(params)
|
|
||||||
processData: false
|
|
||||||
success: (data, status, xhr) ->
|
|
||||||
App.Event.trigger('i18n:translation_update')
|
|
||||||
)
|
|
||||||
|
|
||||||
updateRow: (id) =>
|
updateRow: (id) =>
|
||||||
field = @$("[data-id=#{id}]")
|
field = @$("[data-id=#{id}]")
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li><%- @T('Branding') %></li>
|
<li><%- @T('Branding') %></li>
|
||||||
<li><%- @T('Your Email Configuration') %></li>
|
<li><%- @T('Your Email Configuration') %></li>
|
||||||
<li><%- @T('Invite Agents/Colliges') %></li>
|
<li><%- @T('Invite Agents/Colleges') %></li>
|
||||||
</ul>
|
</ul>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%- @T('How to use it') %>
|
<%- @T('How to use it') %>
|
||||||
|
|
|
@ -7,6 +7,11 @@ class Locale < ApplicationModel
|
||||||
if Rails.env.test?
|
if Rails.env.test?
|
||||||
locales = Locale.where(active: true, locale: ['en-us', 'de-de'])
|
locales = Locale.where(active: true, locale: ['en-us', 'de-de'])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# read used locales based on env, e. g. export Z_LOCALES='en-us:de-de'
|
||||||
|
if ENV['Z_LOCALES']
|
||||||
|
locales = Locale.where(active: true, locale: ENV['Z_LOCALES'].split(':') )
|
||||||
|
end
|
||||||
locales
|
locales
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -195,8 +195,8 @@ get list of translations
|
||||||
]
|
]
|
||||||
list.push translation_item
|
list.push translation_item
|
||||||
end
|
end
|
||||||
data['list'] = list
|
|
||||||
}
|
}
|
||||||
|
data['list'] = list
|
||||||
|
|
||||||
# set cache
|
# set cache
|
||||||
if !admin
|
if !admin
|
||||||
|
@ -234,8 +234,8 @@ translate strings in ruby context, e. g. for notifications
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_initial
|
def set_initial
|
||||||
|
|
||||||
return if target_initial
|
return if target_initial
|
||||||
|
return if target_initial == ''
|
||||||
self.target_initial = target
|
self.target_initial = target
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue