diff --git a/app/assets/javascripts/app/controllers/translation.js.coffee b/app/assets/javascripts/app/controllers/translation.js.coffee
new file mode 100644
index 000000000..309a91d96
--- /dev/null
+++ b/app/assets/javascripts/app/controllers/translation.js.coffee
@@ -0,0 +1,86 @@
+class Index extends App.ControllerContent
+ events:
+ 'blur input': 'update'
+ 'click .js-Reset': 'reset'
+
+ constructor: ->
+ super
+
+ # check authentication
+ return if !@authenticate()
+
+ @title 'Translations'
+
+ @render()
+ @load()
+
+ load: =>
+ @ajax(
+ id: 'translations_admin'
+ type: 'GET'
+ url: @apiPath + '/translations/admin/lang/de'
+ processData: true
+ success: (data, status, xhr) =>
+ @render(data)
+ )
+
+ render: (data = {}) =>
+ @html App.view('translation')(
+ list: data.list
+ timestampFormat: data.timestampFormat
+ dateFormat: data.dateFormat
+ )
+ ui = @
+ @$('.js-Item').each( (e) ->
+ id = $(this).data('id')
+ ui.updateRow(id)
+ )
+
+ reset: (e) ->
+ e.preventDefault()
+ field = $(e.target).closest('tr').find('.js-Item')
+ id = field.data('id')
+ initial = field.data('initial')
+ field.val( initial )
+ @updateRow(id)
+ params =
+ id: id
+ target: initial
+
+ @ajax(
+ id: 'translations'
+ type: 'PUT'
+ url: @apiPath + '/translations/' + id
+ data: JSON.stringify(params)
+ processData: false
+ )
+
+ update: (e) ->
+ e.preventDefault()
+ id = $( e.target ).data('id')
+ target = $( e.target ).val()
+ @updateRow(id)
+ params =
+ id: id
+ target: target
+
+ @ajax(
+ id: 'translations'
+ type: 'PUT'
+ url: @apiPath + '/translations/' + id
+ data: JSON.stringify(params)
+ processData: false
+ )
+
+ updateRow: (id) =>
+ field = @$("[data-id=#{id}]")
+ current = field.val()
+ initial = field.data('initial')
+ reset = field.closest('tr').find('.js-Reset')
+ if current isnt initial
+ reset.show()
+ else
+ reset.hide()
+
+
+App.Config.set( 'Translation', { prio: 1800, parent: '#system', name: 'Translations', target: '#system/translation', controller: Index, role: ['Admin'] }, 'NavBarAdmin' )
diff --git a/app/assets/javascripts/app/views/translation.jst.eco b/app/assets/javascripts/app/views/translation.jst.eco
new file mode 100644
index 000000000..59077d171
--- /dev/null
+++ b/app/assets/javascripts/app/views/translation.jst.eco
@@ -0,0 +1,52 @@
+
+<%- @T('Date & Datetime') %>
+
+
+<%- @T('Words') %>
+
\ No newline at end of file
diff --git a/app/assets/stylesheets/zammad.css.scss b/app/assets/stylesheets/zammad.css.scss
index e5b4d6e58..5872c0f5a 100644
--- a/app/assets/stylesheets/zammad.css.scss
+++ b/app/assets/stylesheets/zammad.css.scss
@@ -5266,6 +5266,23 @@ label + .wizard-buttonList {
.highlight-Purple { background: #eac5ee; }
+.translationOverview {
+ .translationOverview-source {
+ width: 25%;
+ }
+ .translationOverview-target {
+ width: 35%;
+ }
+ .translationOverview-initial {
+ width: 25%;
+ }
+ .translationOverview-action {
+ width: 15%;
+ }
+ .translationOverview-item {
+ width: 100%;
+ }
+}
.overview-navigator {
display: inherit;
diff --git a/app/controllers/translations_controller.rb b/app/controllers/translations_controller.rb
index b4b30ad4a..7dba296f3 100644
--- a/app/controllers/translations_controller.rb
+++ b/app/controllers/translations_controller.rb
@@ -3,11 +3,17 @@
class TranslationsController < ApplicationController
before_filter :authentication_check, :except => [:load]
- # GET /translations/:lang
+ # GET /translations/lang/:locale
def load
render :json => Translation.list( params[:locale] )
end
+ # GET /translations/admin/lang/:locale
+ def admin
+ return if deny_if_not_role(Z_ROLENAME_ADMIN)
+ render :json => Translation.list( params[:locale], true )
+ end
+
# GET /translations
def index
model_index_render(Translation, params)
@@ -20,16 +26,19 @@ class TranslationsController < ApplicationController
# POST /translations
def create
+ return if deny_if_not_role(Z_ROLENAME_ADMIN)
model_create_render(Translation, params)
end
# PUT /translations/1
def update
+ return if deny_if_not_role(Z_ROLENAME_ADMIN)
model_update_render(Translation, params)
end
# DELETE /translations/1
def destroy
+ return if deny_if_not_role(Z_ROLENAME_ADMIN)
model_destory_render(Translation, params)
end
-end
+end
\ No newline at end of file
diff --git a/app/models/translation.rb b/app/models/translation.rb
index 79bc2a2b2..9ce5a24c3 100644
--- a/app/models/translation.rb
+++ b/app/models/translation.rb
@@ -6,24 +6,38 @@ class Translation < ApplicationModel
after_update :cache_clear
after_destroy :cache_clear
- def self.list(locale)
+ def self.list(locale, admin = false)
# check cache
- list = cache_get( locale )
+ if !admin
+ list = cache_get( locale )
+ end
if !list
list = []
- translations = Translation.where( :locale => locale.downcase )
+ translations = Translation.where( :locale => locale.downcase ).order( :source )
translations.each { |item|
- data = [
- item.id,
- item.source,
- item.target,
- ]
- list.push data
+ if admin
+ data = [
+ item.id,
+ item.source,
+ item.target,
+ item.target_initial,
+ ]
+ list.push data
+ else
+ data = [
+ item.id,
+ item.source,
+ item.target,
+ ]
+ list.push data
+ end
}
# set cache
- cache_set( locale, list )
+ if !admin
+ cache_set( locale, list )
+ end
end
timestamp_map_default = 'yyyy-mm-dd HH:MM'
diff --git a/config/routes/translation.rb b/config/routes/translation.rb
index b20e6fc8b..836f67796 100644
--- a/config/routes/translation.rb
+++ b/config/routes/translation.rb
@@ -7,5 +7,6 @@ Zammad::Application.routes.draw do
match api_path + '/translations/:id', :to => 'translations#update', :via => :put
match api_path + '/translations/:id', :to => 'translations#destroy', :via => :delete
- match api_path + '/translations/lang/:locale', :to => 'translations#load', :via => :get
+ match api_path + '/translations/lang/:locale', :to => 'translations#load', :via => :get
+ match api_path + '/translations/admin/lang/:locale', :to => 'translations#admin', :via => :get
end
\ No newline at end of file