The same it's done in the UN official SDG pages. We could try to split the string on a space which is more or less in the middle. However, this wouldn't work on languages which don't have spaces between works, like Chinese. So in the end I've added a new translation key, where the title is supposed to be split in several lines the same way it's done by the UN.
27 lines
564 B
Ruby
27 lines
564 B
Ruby
class SDG::Goals::ShowComponent < ApplicationComponent
|
|
attr_reader :goal
|
|
delegate :back_link_to, to: :helpers
|
|
|
|
def initialize(goal)
|
|
@goal = goal
|
|
end
|
|
|
|
def feeds
|
|
SDG::Widget::Feed.for_goal(goal)
|
|
end
|
|
|
|
private
|
|
|
|
def processes_feed
|
|
feeds.find { |feed| feed.kind == "processes" }
|
|
end
|
|
|
|
def heading
|
|
safe_join([tag.span(goal.code, class: "goal-code"), tag.span(split_title, class: "goal-title")], " ")
|
|
end
|
|
|
|
def split_title
|
|
safe_join(goal.multiline_title.split("\n").map { |text| tag.span(text) }, " ")
|
|
end
|
|
end
|