knowledge_base_public_page_title_helper.rb 748 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module KnowledgeBasePublicPageTitleHelper
  3. def kb_public_page_title(leading, trailing, exception)
  4. [
  5. leading&.translation&.title,
  6. kb_public_page_title_suffix(trailing, exception)
  7. ].compact.join(' - ')
  8. end
  9. def kb_public_page_title_suffix(item, exception)
  10. case item
  11. when HasTranslations
  12. return item&.translation&.title if exception.blank?
  13. zt kb_public_page_title_suffix_exception(exception)
  14. when String
  15. item
  16. end
  17. end
  18. def kb_public_page_title_suffix_exception(exception)
  19. case exception
  20. when :not_found
  21. __('Not Found')
  22. when :alternatives
  23. __('Alternative Translations')
  24. end
  25. end
  26. end