From d5f48bb195c0be9f3d39dd446c821404d05ba06a Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Fri, 26 Nov 2021 08:08:02 +0100 Subject: [PATCH] Follow-up: 1f5d1bf8d3a65943047d780ac4fee90ff7b62850 - Increase translation string length to handle existing description strings properly. --- app/assets/javascripts/app/models/sla.coffee | 4 +-- .../javascripts/app/models/text_module.coffee | 10 +++--- .../javascripts/app/models/trigger.coffee | 4 +-- .../translation/synchronizes_from_po.rb | 4 +-- db/migrate/20120101000001_create_base.rb | 16 ++++----- ...0211126064735_translation_string_length.rb | 14 ++++++++ i18n/zammad.pot | 34 ++----------------- .../translation_catalog/extractor/base.rb | 4 +-- .../translation_catalog/extractor/erb_spec.rb | 4 +-- .../extractor/frontend_spec.rb | 4 +-- .../extractor/ruby_spec.rb | 4 +-- .../translation_synchronizes_from_po_spec.rb | 2 +- 12 files changed, 46 insertions(+), 58 deletions(-) create mode 100644 db/migrate/20211126064735_translation_string_length.rb diff --git a/app/assets/javascripts/app/models/sla.coffee b/app/assets/javascripts/app/models/sla.coffee index 77f1dbb19..dc3db3cf5 100644 --- a/app/assets/javascripts/app/models/sla.coffee +++ b/app/assets/javascripts/app/models/sla.coffee @@ -23,8 +23,8 @@ class App.Sla extends App.Model @description = __(''' ** Service Level Agreements **, abbreviated ** SLAs **, help you to meet certain customers' time-related responses. Thus, for example, you can say customers should always get a response from you after 8 hours at the latest. In the event of an imminent violation or a breach, Zammad will alert you to such events. -''') + '\n\n' + __(''' + It can be ** response time ** (time between the creation of a ticket and the first reaction of an agent), ** update time ** (time between a customer's request and an agent's reaction) and ** solution time ** (time between creation and closing a ticket ) To be defined. -''') + '\n\n' + __(''' + Any violations are displayed in a separate view in the overviews. You can also configure ** e-mail notifications **. ''') diff --git a/app/assets/javascripts/app/models/text_module.coffee b/app/assets/javascripts/app/models/text_module.coffee index 4f4eff5ee..48c2c8702 100644 --- a/app/assets/javascripts/app/models/text_module.coffee +++ b/app/assets/javascripts/app/models/text_module.coffee @@ -39,22 +39,24 @@ class App.TextModule extends App.Model # coffeelint: disable=no_interpolation_in_single_quotes @description = __(''' Create Text Modules to **spend less time writing responses**. Text Modules can include smart variables like the users name or email address. -''') + '\n\n' + __(''' + Examples of snippets are: + * Hello Mrs. #{ticket.customer.lastname}, * Hello Mr. #{ticket.customer.lastname}, * Hello #{ticket.customer.firstname}, * My Name is #{user.firstname}, -''') + '\n\n' + __(''' + Of course you can also use multi line snippets. -''') + '\n\n' + __(''' + Available objects are: * ticket (e. g. ticket.state, ticket.group) * ticket.customer (e. g. ticket.customer.firstname, ticket.customer.lastname) * ticket.owner (e. g. ticket.owner.firstname, ticket.owner.lastname) * ticket.organization (e. g. ticket.organization.name) * user (e. g. user.firstname, user.email) -''') + '\n\n' + __(''' + To select placeholders from a list, just enter "::". + ''') # coffeelint: enable=no_interpolation_in_single_quotes diff --git a/app/assets/javascripts/app/models/trigger.coffee b/app/assets/javascripts/app/models/trigger.coffee index 623b573c3..c67c19460 100644 --- a/app/assets/javascripts/app/models/trigger.coffee +++ b/app/assets/javascripts/app/models/trigger.coffee @@ -17,8 +17,8 @@ class App.Trigger extends App.Model @description = __(''' Every time a customer creates a new ticket, they automatically receive a confirmation email to assure them that their issue has been submitted successfully. This behavior is built into Zammad, but it’s also highly customizable, and you can set up other automated actions just like it. -''') + '\n\n' + __(''' + Maybe you want to set a higher priority on any ticket with the word “urgent” in the title. Maybe you want to avoid sending auto-reply emails to customers from certain organizations. Maybe you want mark a ticket as “pending” whenever someone adds an internal note to a ticket. -''') + '\n\n' + __(''' + Whatever it is, you can do it with triggers: actions that watch tickets for certain changes, and then fire off whenever those changes occur. ''') diff --git a/app/models/translation/synchronizes_from_po.rb b/app/models/translation/synchronizes_from_po.rb index 697869db0..47158d75b 100644 --- a/app/models/translation/synchronizes_from_po.rb +++ b/app/models/translation/synchronizes_from_po.rb @@ -23,8 +23,8 @@ module Translation::SynchronizesFromPo strings_for_locale(locale).each_pair do |source, entry| # rubocop:disable Metrics/BlockLength - if source.length > 500 || entry.translation.length > 500 - Rails.logger.error "Cannot import translation for locale #{locale} because it exceeds maximum string length of 500: source: '#{source}', translation: '#{entry.translation}'" + if source.length > 3000 || entry.translation.length > 3000 + Rails.logger.error "Cannot import translation for locale #{locale} because it exceeds maximum string length of 3000: source: '#{source}', translation: '#{entry.translation}'" next end diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index a21d5dfd5..f1b9ae91b 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -227,15 +227,15 @@ class CreateBase < ActiveRecord::Migration[4.2] add_index :locales, [:name], unique: true create_table :translations do |t| - t.string :locale, limit: 10, null: false - t.string :source, limit: 500, null: false - t.string :target, limit: 500, null: false - t.string :target_initial, limit: 500, null: false - t.boolean :is_synchronized_from_codebase, null: false, default: false + t.string :locale, limit: 10, null: false + t.string :source, limit: 3000, null: false + t.string :target, limit: 3000, null: false + t.string :target_initial, limit: 3000, null: false + t.boolean :is_synchronized_from_codebase, null: false, default: false t.string :synchronized_from_translation_file, limit: 255 - t.integer :updated_by_id, null: false - t.integer :created_by_id, null: false - t.timestamps limit: 3, null: false + t.integer :updated_by_id, null: false + t.integer :created_by_id, null: false + t.timestamps limit: 3, null: false end add_index :translations, [:source], length: 255 add_index :translations, [:locale] diff --git a/db/migrate/20211126064735_translation_string_length.rb b/db/migrate/20211126064735_translation_string_length.rb new file mode 100644 index 000000000..466c60c1d --- /dev/null +++ b/db/migrate/20211126064735_translation_string_length.rb @@ -0,0 +1,14 @@ +# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ + +class TranslationStringLength < ActiveRecord::Migration[6.0] + def change + # return if it's a new setup + return if !Setting.exists?(name: 'system_init_done') + + # Increase translation string length from 500 to 3000. + change_column(:translations, :source, :string, limit: 3000) + change_column(:translations, :target, :string, limit: 3000) + change_column(:translations, :target_initial, :string, limit: 3000) + Translation.reset_column_information + end +end diff --git a/i18n/zammad.pot b/i18n/zammad.pot index e04939c88..6299b46d2 100644 --- a/i18n/zammad.pot +++ b/i18n/zammad.pot @@ -245,7 +245,7 @@ msgid "** Data Privacy **, helps you to delete and verify the removal of existin msgstr "" #: app/assets/javascripts/app/models/sla.coffee -msgid "** Service Level Agreements **, abbreviated ** SLAs **, help you to meet certain customers' time-related responses. Thus, for example, you can say customers should always get a response from you after 8 hours at the latest. In the event of an imminent violation or a breach, Zammad will alert you to such events." +msgid "** Service Level Agreements **, abbreviated ** SLAs **, help you to meet certain customers' time-related responses. Thus, for example, you can say customers should always get a response from you after 8 hours at the latest. In the event of an imminent violation or a breach, Zammad will alert you to such events.\n\nIt can be ** response time ** (time between the creation of a ticket and the first reaction of an agent), ** update time ** (time between a customer's request and an agent's reaction) and ** solution time ** (time between creation and closing a ticket ) To be defined.\n\nAny violations are displayed in a separate view in the overviews. You can also configure ** e-mail notifications **." msgstr "" #: app/assets/javascripts/app/controllers/_plugin/keyboard_shortcuts.coffee @@ -793,10 +793,6 @@ msgstr "" msgid "Any Recipient" msgstr "" -#: app/assets/javascripts/app/models/sla.coffee -msgid "Any violations are displayed in a separate view in the overviews. You can also configure ** e-mail notifications **." -msgstr "" - #: db/seeds/settings.rb msgid "App ID" msgstr "" @@ -1078,10 +1074,6 @@ msgstr "" msgid "Available for the following roles" msgstr "" -#: app/assets/javascripts/app/models/text_module.coffee -msgid "Available objects are:\n* ticket (e. g. ticket.state, ticket.group)\n* ticket.customer (e. g. ticket.customer.firstname, ticket.customer.lastname)\n* ticket.owner (e. g. ticket.owner.firstname, ticket.owner.lastname)\n* ticket.organization (e. g. ticket.organization.name)\n* user (e. g. user.firstname, user.email)" -msgstr "" - #: db/seeds/settings.rb msgid "Available types for a new ticket" msgstr "" @@ -2085,7 +2077,7 @@ msgid "Create Text Modules" msgstr "" #: app/assets/javascripts/app/models/text_module.coffee -msgid "Create Text Modules to **spend less time writing responses**. Text Modules can include smart variables like the users name or email address." +msgid "Create Text Modules to **spend less time writing responses**. Text Modules can include smart variables like the users name or email address.\n\nExamples of snippets are:\n\n* Hello Mrs. #{ticket.customer.lastname},\n* Hello Mr. #{ticket.customer.lastname},\n* Hello #{ticket.customer.firstname},\n* My Name is #{user.firstname},\n\nOf course you can also use multi line snippets.\n\nAvailable objects are:\n* ticket (e. g. ticket.state, ticket.group)\n* ticket.customer (e. g. ticket.customer.firstname, ticket.customer.lastname)\n* ticket.owner (e. g. ticket.owner.firstname, ticket.owner.lastname)\n* ticket.organization (e. g. ticket.organization.name)\n* user (e. g. user.firstname, user.email)\n\nTo select placeholders from a list, just enter \"::\".\n" msgstr "" #: app/controllers/first_steps_controller.rb @@ -3745,7 +3737,7 @@ msgid "Every category in your knowledge base should be given a unique icon for m msgstr "" #: app/assets/javascripts/app/models/trigger.coffee -msgid "Every time a customer creates a new ticket, they automatically receive a confirmation email to assure them that their issue has been submitted successfully. This behavior is built into Zammad, but it’s also highly customizable, and you can set up other automated actions just like it." +msgid "Every time a customer creates a new ticket, they automatically receive a confirmation email to assure them that their issue has been submitted successfully. This behavior is built into Zammad, but it’s also highly customizable, and you can set up other automated actions just like it.\n\nMaybe you want to set a higher priority on any ticket with the word “urgent” in the title. Maybe you want to avoid sending auto-reply emails to customers from certain organizations. Maybe you want mark a ticket as “pending” whenever someone adds an internal note to a ticket.\n\nWhatever it is, you can do it with triggers: actions that watch tickets for certain changes, and then fire off whenever those changes occur." msgstr "" #: app/assets/javascripts/app/views/api.jst.eco @@ -3765,10 +3757,6 @@ msgstr "" msgid "Examples" msgstr "" -#: app/assets/javascripts/app/models/text_module.coffee -msgid "Examples of snippets are:\n* Hello Mrs. #{ticket.customer.lastname},\n* Hello Mr. #{ticket.customer.lastname},\n* Hello #{ticket.customer.firstname},\n* My Name is #{user.firstname}," -msgstr "" - #: app/assets/javascripts/app/controllers/_manage/ticket_auto_assignment.coffee msgid "Exception users" msgstr "" @@ -5138,10 +5126,6 @@ msgstr "" msgid "Ionicons" msgstr "" -#: app/assets/javascripts/app/models/sla.coffee -msgid "It can be ** response time ** (time between the creation of a ticket and the first reaction of an agent), ** update time ** (time between a customer's request and an agent's reaction) and ** solution time ** (time between creation and closing a ticket ) To be defined." -msgstr "" - #: app/assets/javascripts/app/controllers/ticket_overview.coffee msgid "Items per page" msgstr "" @@ -5681,10 +5665,6 @@ msgstr "" msgid "May" msgstr "" -#: app/assets/javascripts/app/models/trigger.coffee -msgid "Maybe you want to set a higher priority on any ticket with the word “urgent” in the title. Maybe you want to avoid sending auto-reply emails to customers from certain organizations. Maybe you want mark a ticket as “pending” whenever someone adds an internal note to a ticket." -msgstr "" - #: app/assets/javascripts/app/views/layout_ref/organization_profile.jst.eco #: app/assets/javascripts/app/views/organization_profile/object.jst.eco #: app/assets/javascripts/app/views/popover/organization.jst.eco @@ -6693,10 +6673,6 @@ msgstr "" msgid "October" msgstr "" -#: app/assets/javascripts/app/models/text_module.coffee -msgid "Of course you can also use multi line snippets." -msgstr "" - #: app/assets/javascripts/app/controllers/_profile/linked_accounts.coffee #: db/seeds/settings.rb msgid "Office 365" @@ -10364,10 +10340,6 @@ msgstr "" msgid "What values of %s should be synced to users." msgstr "" -#: app/assets/javascripts/app/models/trigger.coffee -msgid "Whatever it is, you can do it with triggers: actions that watch tickets for certain changes, and then fire off whenever those changes occur." -msgstr "" - #: app/assets/javascripts/app/controllers/_integration/slack.coffee msgid "When notification is being sent." msgstr "" diff --git a/lib/generators/translation_catalog/extractor/base.rb b/lib/generators/translation_catalog/extractor/base.rb index 442d1b75e..8d527c639 100644 --- a/lib/generators/translation_catalog/extractor/base.rb +++ b/lib/generators/translation_catalog/extractor/base.rb @@ -17,8 +17,8 @@ class Generators::TranslationCatalog::Extractor::Base def validate_strings @strings.to_a.each do |s| - if s.length > 500 - raise "Found a string that longer than than the allowed 500 characters: '#{s}'" + if s.length > 3000 + raise "Found a string that longer than than the allowed 3000 characters: '#{s}'" end end end diff --git a/spec/lib/generators/translation_catalog/extractor/erb_spec.rb b/spec/lib/generators/translation_catalog/extractor/erb_spec.rb index f780fba66..0d1acb8d8 100644 --- a/spec/lib/generators/translation_catalog/extractor/erb_spec.rb +++ b/spec/lib/generators/translation_catalog/extractor/erb_spec.rb @@ -44,12 +44,12 @@ RSpec.describe Generators::TranslationCatalog::Extractor::Erb do context 'with strings too long' do let(:string) do <<~"CODE" - <%= t("#{'a' * 501}") %> + <%= t("#{'a' * 3001}") %> CODE end it 'raises an error' do - expect { result_strings }.to raise_error(%r{Found a string that longer than than the allowed 500 characters}) + expect { result_strings }.to raise_error(%r{Found a string that longer than than the allowed 3000 characters}) end end end diff --git a/spec/lib/generators/translation_catalog/extractor/frontend_spec.rb b/spec/lib/generators/translation_catalog/extractor/frontend_spec.rb index 74ad0d3b2..b1b101c6b 100644 --- a/spec/lib/generators/translation_catalog/extractor/frontend_spec.rb +++ b/spec/lib/generators/translation_catalog/extractor/frontend_spec.rb @@ -46,12 +46,12 @@ RSpec.describe Generators::TranslationCatalog::Extractor::Frontend do context 'with strings too long' do let(:string) do <<~"CODE" - __("#{'a' * 501}") + __("#{'a' * 3001}") CODE end it 'raises an error' do - expect { result_strings }.to raise_error(%r{Found a string that longer than than the allowed 500 characters}) + expect { result_strings }.to raise_error(%r{Found a string that longer than than the allowed 3000 characters}) end end end diff --git a/spec/lib/generators/translation_catalog/extractor/ruby_spec.rb b/spec/lib/generators/translation_catalog/extractor/ruby_spec.rb index 46d8449f8..46833f4d1 100644 --- a/spec/lib/generators/translation_catalog/extractor/ruby_spec.rb +++ b/spec/lib/generators/translation_catalog/extractor/ruby_spec.rb @@ -45,12 +45,12 @@ RSpec.describe Generators::TranslationCatalog::Extractor::Ruby do context 'with strings too long' do let(:string) do <<~"CODE" - __("#{'a' * 501}") + __("#{'a' * 3001}") CODE end it 'raises an error' do - expect { result_strings }.to raise_error(%r{Found a string that longer than than the allowed 500 characters}) + expect { result_strings }.to raise_error(%r{Found a string that longer than than the allowed 3000 characters}) end end end diff --git a/spec/models/translation/translation_synchronizes_from_po_spec.rb b/spec/models/translation/translation_synchronizes_from_po_spec.rb index 646aea6f2..fdce983bb 100644 --- a/spec/models/translation/translation_synchronizes_from_po_spec.rb +++ b/spec/models/translation/translation_synchronizes_from_po_spec.rb @@ -178,7 +178,7 @@ RSpec.describe Translation do msgstr "custom-string-übersetzt" msgid "custom-string-too-long" - msgstr "custom-string-too-long #{'a' * 501}" + msgstr "custom-string-too-long #{'a' * 3001}" msgid "custom-string-untranslated" msgstr ""