Просмотр исходного кода

Fixes #4323 - Missing and unapplied translations in GUI.

Dusan Vuckovic 2 лет назад
Родитель
Сommit
15cff9257d

+ 1 - 1
app/assets/javascripts/app/controllers/_application_controller/_generic_index.coffee

@@ -114,7 +114,7 @@ class App.ControllerGenericIndex extends App.Controller
 
       # show description in content if no no content exists
       if _.isEmpty(objects) && App[ @genericObject ].description
-        description = marked(App[ @genericObject ].description)
+        description = marked(App.i18n.translateContent(App[ @genericObject ].description))
         @$('.table-overview').html(description)
         return
 

+ 1 - 1
app/assets/javascripts/app/controllers/_application_controller/form.coffee

@@ -130,7 +130,7 @@ class App.ControllerForm extends App.Controller
 
         # rename display and name to _confirm
         if !attribute.single
-          attribute.display = attribute.display + ' (confirm)'
+          attribute.display = App.i18n.translateContent('%s (confirm)', App.i18n.translateContent(attribute.display))
           attribute.name = attribute.name + '_confirm'
           item = @formGenItem(attribute, @idPrefix, fieldset, attributeCount)
           item.appendTo(fieldset)

+ 6 - 6
app/assets/javascripts/app/controllers/_integration/slack.coffee

@@ -19,14 +19,14 @@ class Slack extends App.ControllerIntegrationBase
       params = params.items[0] || {}
 
     options =
-      create: '1. Ticket Create'
-      update: '2. Ticket Update'
-      reminder_reached: '3. Ticket Reminder Reached'
-      escalation: '4. Ticket Escalation'
-      escalation_warning: '5. Ticket Escalation Warning'
+      create: __('1. Ticket Create')
+      update: __('2. Ticket Update')
+      reminder_reached: __('3. Ticket Reminder Reached')
+      escalation: __('4. Ticket Escalation')
+      escalation_warning: __('5. Ticket Escalation Warning')
 
     configureAttributes = [
-      { name: 'types',     display: __('Trigger'),  tag: 'checkbox', options: options, 'null': false, class: 'vertical', note: __('When notification is being sent.') },
+      { name: 'types',     display: __('Trigger'),  tag: 'checkbox', options: options, translate: true, 'null': false, class: 'vertical', note: __('When notification is being sent.') },
       { name: 'group_ids', display: __('Group'),    tag: 'select', relation: 'Group', multiple: true, 'null': false, class: 'form-control--small', note: __('Only for these groups.') },
       { name: 'webhook',   display: __('Webhook'),  tag: 'input', type: 'url',  limit: 200, 'null': false, class: 'form-control--small', placeholder: 'https://hooks.slack.com/services/...' },
       { name: 'username',  display: __('Username'), tag: 'input', type: 'text', limit: 100, 'null': false, class: 'form-control--small', placeholder: 'username' },

+ 3 - 0
app/assets/javascripts/app/controllers/_ui_element/_application/_ui_element.coffee

@@ -158,6 +158,9 @@ class App.UiElement.ApplicationUiElement
       App.Log.debug 'ControllerForm', '_getRelationOptionList:filter-no filter defined'
       list = App[ attribute.relation ].search(sortBy: attribute.sortBy)
 
+    # Turn on attribute translation if configured for the relation object.
+    attribute.translate = App[ attribute.relation ].configure_translate
+
     App.Log.debug 'ControllerForm', '_getRelationOptionList', attribute, list
 
     # build options list

+ 5 - 0
app/assets/javascripts/app/controllers/_ui_element/boolean.coffee

@@ -11,6 +11,11 @@ class App.UiElement.boolean extends App.UiElement.ApplicationUiElement
       ]
       attribute.translate = true
 
+    # Turn on option translation if the list contains expected labels.
+    else if _.isObject(attribute.options) and _.every(_.values(attribute.options), (value) -> /^(yes|no)$/i.test(value)) or
+            _.isArray(attribute.options) and _.every(attribute.options, (option) -> /^(yes|no)$/i.test(option.value))
+      attribute.translate = true
+
     # build options list based on config
     @getConfigOptionList(attribute, params)
 

+ 4 - 1
app/assets/javascripts/app/controllers/_ui_element/object_manager_attribute.coffee

@@ -93,6 +93,9 @@ class App.UiElement.object_manager_attribute extends App.UiElement.ApplicationUi
     item
 
   @dataScreens: (attribute, localParams, params) ->
+    # TODO: find a better place for these translation markers, since they are used only in keys below!
+    #   __('shown')
+    #   __('required')
     object = params.object
     objects =
       Ticket:
@@ -232,7 +235,7 @@ class App.UiElement.object_manager_attribute extends App.UiElement.ApplicationUi
     )
     configureAttributes = [
       # coffeelint: disable=no_interpolation_in_single_quotes
-      { name: 'data_option::linktemplate', display: __('Link Template'), tag: 'input', type: 'text', null: true, default: '', placeholder: 'https://example.com/?q=#{object.attribute_name} - use ticket, user or organization as object' },
+      { name: 'data_option::linktemplate', display: __('Link Template'), tag: 'input', type: 'text', null: true, default: '', placeholder: __('https://example.com/?q=#{object.attribute_name} - use ticket, user or organization as object') },
       # coffeelint: enable=no_interpolation_in_single_quotes
     ]
     inputLinkTemplate = new App.ControllerForm(

+ 10 - 10
app/assets/javascripts/app/controllers/layout_ref.coffee

@@ -1364,7 +1364,7 @@ class SlaRef extends App.ControllerAppContent
       head: 'Service Level Agreement (SLA)'
       headPrefox: 'New'
       contentInline: App.view('layout_ref/sla_modal')()
-      buttonSubmit: __('Create SLA')
+      buttonSubmit: 'Create SLA'
       shown: true
       buttonCancel: true
       container: @el
@@ -1403,7 +1403,7 @@ class SchedulersRef extends App.ControllerAppContent
     new App.ControllerModal
       head: 'Scheduler'
       headPrefix: 'New'
-      buttonSubmit: __('Create')
+      buttonSubmit: 'Create'
       buttonCancel: true
       contentInline: App.view('layout_ref/scheduler_modal')()
       shown: true
@@ -1473,7 +1473,7 @@ class InputsRef extends App.ControllerAppContent
       attribute:
         name:        'project-name'
         id:          'project-name-123'
-        placeholder: __('Enter Project Name')
+        placeholder: 'Enter Project Name'
         options:     [{value:0,name:'Apple',selected:true},
         {value:1,name:'Microsoft',selected:true},
         {value:2,name:'Google'},
@@ -1500,7 +1500,7 @@ class InputsRef extends App.ControllerAppContent
       attribute:
         name:        'user'
         id:          'user-123'
-        placeholder: __('Enter User')
+        placeholder: 'Enter User'
         limt:        10
         relation:    'User'
 
@@ -1510,7 +1510,7 @@ class InputsRef extends App.ControllerAppContent
     userOrganizationAutocomplete = new App.UserOrganizationAutocompletion
       attribute:
         name: 'customer_id'
-        display: __('Customer')
+        display: 'Customer'
         tag: 'user_autocompletion'
         type: 'text'
         limit: 200
@@ -1739,7 +1739,7 @@ class MergeCustomerRef extends App.ControllerAppContent
       head: "#{@mergeSource.firstname} #{@mergeSource.lastname}"
       headPrefix: 'Merge'
       contentInline: App.view('layout_ref/merge_customer')()
-      buttonSubmit: __('Merge')
+      buttonSubmit: 'Merge'
       buttonCancel: true
       container: @el
 
@@ -2407,14 +2407,14 @@ class KnowledgeBaseLinkAnswerToAnswerRef extends App.ControllerAppContent
           {
             name: 'translation::title'
             model: 'translation'
-            display: __('Title')
+            display: 'Title'
             tag: 'input'
             grid_width: '1/2'
           }
           {
             name: 'category_id'
             model: 'answer'
-            display: __('Category')
+            display: 'Category'
             tag: 'select'
             null: true
             options: [
@@ -2432,7 +2432,7 @@ class KnowledgeBaseLinkAnswerToAnswerRef extends App.ControllerAppContent
           {
             name: 'translation::content::body'
             model: 'translation'
-            display: __('Content')
+            display: 'Content'
             tag: 'richtext'
             buttons: [
               'link'
@@ -2443,4 +2443,4 @@ class KnowledgeBaseLinkAnswerToAnswerRef extends App.ControllerAppContent
     )
 
 App.Config.set('layout_ref/kb_link_answer_to_answer', KnowledgeBaseLinkAnswerToAnswerRef, 'Routes')
-App.Config.set('LayoutRef', { prio: 1600, parent: '#current_user', name: 'Layout Reference', translate: true, target: '#layout_ref', permission: [ 'admin' ], setting: ['developer_mode'] }, 'NavBarRight')
+App.Config.set('LayoutRef', { prio: 1600, parent: '#current_user', name: __('Layout Reference'), translate: true, target: '#layout_ref', permission: [ 'admin' ], setting: ['developer_mode'] }, 'NavBarRight')

+ 1 - 1
app/assets/javascripts/app/controllers/sla.coffee

@@ -35,7 +35,7 @@ class Sla extends App.ControllerSubContent
       if !_.isEmpty(slas)
         showDescription = true
       else
-        description = marked(App.Sla.description)
+        description = marked(App.i18n.translateContent(App.Sla.description))
 
     @html App.view('sla/index')(
       slas:            slas

+ 2 - 0
app/assets/javascripts/app/models/chat_sessions.coffee

@@ -18,6 +18,8 @@ class App.ChatSession extends App.Model
     'created_at',
   ]
 
+  @display_name = __('Chat Session')
+
   uiUrl: ->
     "#customer_chat/session/#{@id}"
 

+ 3 - 3
app/assets/javascripts/app/models/overview.coffee

@@ -3,12 +3,12 @@ class App.Overview extends App.Model
   @extend Spine.Model.Ajax
   @url: @apiPath + '/overviews'
   @configure_attributes = [
-    { name: 'name',       display: __('Name'),                tag: 'input',    type: 'text', limit: 100, 'null': false },
+    { name: 'name',       display: __('Name'),                tag: 'input',    type: 'text', translate: true, limit: 100, 'null': false },
     { name: 'link',       display: __('Link'),                readonly: 1 },
     { name: 'role_ids',   display: __('Available for the following roles'),    tag: 'column_select', multiple: true, null: false, relation: 'Role', translate: true },
     { name: 'user_ids',   display: __('Restrict to only the following users'), tag: 'column_select', multiple: true, null: true,  relation: 'User', sortBy: 'firstname' },
-    { name: 'organization_shared', display: __('Only available for Users with shared Organizations'), tag: 'select', options: { true: 'yes', false: 'no' }, default: false, null: true },
-    { name: 'out_of_office', display: __('Only available for Users which are replacements for other users.'), tag: 'select', options: { true: 'yes', false: 'no' }, default: false, null: true },
+    { name: 'organization_shared', display: __('Only available for Users with shared Organizations'), tag: 'select', options: { true: 'yes', false: 'no' }, translate: true, default: false, null: true },
+    { name: 'out_of_office', display: __('Only available for Users which are replacements for other users.'), tag: 'select', options: { true: 'yes', false: 'no' }, translate: true, default: false, null: true },
     { name: 'condition',  display: __('Conditions for shown Tickets'), tag: 'ticket_selector', null: false, out_of_office: true },
     { name: 'prio',       display: __('Prio'),                readonly: 1 },
     {

Некоторые файлы не были показаны из-за большого количества измененных файлов