extracted_string.rb 731 B

12345678910111213141516171819202122232425
  1. # Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. class Zammad::TranslationCatalog::ExtractedString
  3. attr_accessor :string, :comment, :references, :skip_translation_sync
  4. def initialize(string:, references:, comment: nil, skip_translation_sync: false)
  5. @string = string
  6. @comment = comment
  7. @references = Set.new(references)
  8. @skip_translation_sync = skip_translation_sync
  9. end
  10. def merge!(other)
  11. if @string != other.string
  12. raise 'Cannot merge different strings.'
  13. end
  14. if other.comment
  15. @comment ||= ''
  16. @comment += other.comment
  17. end
  18. @references = references.merge other.references
  19. @skip_translation_sync &= other.skip_translation_sync
  20. end
  21. end