govuk_publishing_components 23.7.1 → 23.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63eb3e251bfdd3c16215cc72dbe7a225ba84dff4d1aac2fecfa393a17f737a59
4
- data.tar.gz: 6645fbe499447ded996095c91e01a4e34ba1fc83e9b14bb872f1bc713798d2b8
3
+ metadata.gz: 4b65d39a36c66fce7a8137823bfc36e49e0da0a079aca53915b3d45285cae845
4
+ data.tar.gz: 34d3d5d5e175fa52e7ee61e5f259828a60d767d8b19bcc5c002010b3448a531c
5
5
  SHA512:
6
- metadata.gz: 552b029895c0c121224f830891ac14c874557765be7abadb8e9527bb9ad658b7e3bf8ce142bc278391da411b25b3750578b386814c151ece65cd0588570a90d4
7
- data.tar.gz: e339ad09ad94a7286ae59a559ba2b172068998f6e98c2c3f0257b4991e99e8e6dfde8781dfdc256478764c2cee5d107705a07f1dee02b05cb9d1c03554840e1a
6
+ metadata.gz: 64e67eaa447d97a8e42304b59c836e08131bde424cff2dac6631fae05bf035aa793d90a6987fd5af1777a6fe00e50d71f5cc176d9fc992ad8e0159ea649792f9
7
+ data.tar.gz: 59b458f62f226e28be467e1ae9c8eb4e7b5fde87dfbb09fdfe7eeb40c83190f91ecc1a3702973e459000bcb62318d5f30420c431a3b138ef28dc3807669f57a4
@@ -1,4 +1,5 @@
1
1
  <% navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request) %>
2
+ <% shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) %>
2
3
 
3
4
  <div class="gem-c-contextual-sidebar">
4
5
  <% if navigation.show_brexit_cta? && navigation.step_by_step_count.zero? %>
@@ -16,7 +17,7 @@
16
17
  "track-dimension": t("components.related_navigation.transition.link_text"),
17
18
  "track-dimension-index": "29",
18
19
  },
19
- lang: I18n.locale,
20
+ lang: shared_helper.t_locale("components.related_navigation.transition.title"),
20
21
  } %>
21
22
  <% end %>
22
23
 
@@ -1,4 +1,5 @@
1
1
  <% related_nav_helper = GovukPublishingComponents::Presenters::RelatedNavigationHelper.new(local_assigns) %>
2
+ <% shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) %>
2
3
 
3
4
  <% if related_nav_helper.related_navigation? %>
4
5
  <% random = SecureRandom.hex(4) %>
@@ -8,7 +9,7 @@
8
9
  <h2 id="related-nav-related_items-<%= random %>"
9
10
  class="gem-c-related-navigation__main-heading"
10
11
  data-track-count="sidebarRelatedItemSection"
11
- <%= related_nav_helper.t_lang(
12
+ <%= shared_helper.t_lang(
12
13
  "components.related_#{local_assigns[:context]}_navigation.related_content",
13
14
  default: 'components.related_navigation.related_content'
14
15
  )
@@ -28,6 +29,7 @@
28
29
 
29
30
  <%= render 'govuk_publishing_components/components/related_navigation/section',
30
31
  related_nav_helper: related_nav_helper,
32
+ shared_helper: shared_helper,
31
33
  section_title: section_title,
32
34
  links: links,
33
35
  section_index: section_index,
@@ -7,10 +7,11 @@
7
7
  text ||= nil
8
8
  url ||= nil
9
9
  data_attributes ||= {}
10
- lang ||= 'en'
10
+ lang ||= "en"
11
+ direction ||= "ltr"
11
12
  css_classes = %w(gem-c-transition-countdown)
12
- css_classes << 'gem-c-transition-countdown--cta' if url
13
- css_classes << 'govuk-link' if url
13
+ css_classes << "gem-c-transition-countdown--cta" if url
14
+ css_classes << "govuk-link" if url
14
15
  %>
15
16
 
16
17
  <% countdown = capture do %>
@@ -24,11 +25,11 @@
24
25
  <% end %>
25
26
 
26
27
  <% if url %>
27
- <%= link_to url, class: css_classes, data: data_attributes, lang: lang do %>
28
+ <%= link_to url, class: css_classes, data: data_attributes, lang: lang, dir: direction do %>
28
29
  <%= countdown %>
29
30
  <% end %>
30
31
  <% else %>
31
- <%= tag.div class: css_classes, lang: lang do %>
32
+ <%= tag.div class: css_classes, lang: lang, dir: direction do %>
32
33
  <%= countdown %>
33
34
  <% end %>
34
35
  <% end %>
@@ -28,7 +28,7 @@
28
28
  link[:path],
29
29
  class: related_nav_helper.section_css_class("gem-c-related-navigation__section-link", section_title, link, (index >= section_link_limit)),
30
30
  rel: link[:rel],
31
- lang: related_nav_helper.t_locale_check(link[:locale]),
31
+ lang: shared_helper.t_locale_check(link[:locale]),
32
32
  data: {
33
33
  track_category: 'relatedLinkClicked',
34
34
  track_action: "#{section_index}.#{index} #{related_nav_helper.construct_section_heading(section_title) || t('components.related_navigation.related_content')}",
@@ -97,48 +97,8 @@ module GovukPublishingComponents
97
97
  related_navigation.flat_map(&:last).any?
98
98
  end
99
99
 
100
- def t_locale(content, options = {})
101
- # Check if the content string has a translation
102
- content_translation_available = translation_present?(content)
103
-
104
- # True, return locale
105
- this_locale = I18n.locale if content_translation_available
106
- # If false, return default locale
107
- this_locale = I18n.default_locale unless content_translation_available
108
-
109
- # Check if default string passed in
110
- if options[:default].present?
111
- # Check if the default string has a translation
112
- default_translation_available = translation_present?(options[:default])
113
- # If true, return locale
114
- this_locale = I18n.locale if default_translation_available
115
- # If false, return default_locale
116
- this_locale = I18n.default_locale unless default_translation_available
117
- end
118
-
119
- this_locale
120
- end
121
-
122
- def t_lang(content, options = {})
123
- locale = t_locale(content, options)
124
- "lang=#{locale}" unless locale.eql?(I18n.locale)
125
- end
126
-
127
- def t_locale_check(locale)
128
- locale.presence unless locale.to_s.eql?(I18n.locale.to_s)
129
- end
130
-
131
100
  private
132
101
 
133
- def translation_present?(content)
134
- default_string = "This is a string to act as a default for the `I18n.translate` method. Comparing the result reveals if there is a translation in the i18n files."
135
- I18n.translate(
136
- content,
137
- default: default_string,
138
- fallback: false,
139
- ) != default_string
140
- end
141
-
142
102
  def related_items
143
103
  related_quick_links = content_item_details_for("quick_links")
144
104
 
@@ -30,6 +30,48 @@ module GovukPublishingComponents
30
30
 
31
31
  "span"
32
32
  end
33
+
34
+ def t_locale(content, options = {})
35
+ # Check if the content string has a translation
36
+ content_translation_available = translation_present?(content)
37
+
38
+ # True, return locale
39
+ this_locale = I18n.locale if content_translation_available
40
+ # If false, return default locale
41
+ this_locale = I18n.default_locale unless content_translation_available
42
+
43
+ # Check if default string passed in
44
+ if options[:default].present?
45
+ # Check if the default string has a translation
46
+ default_translation_available = translation_present?(options[:default])
47
+ # If true, return locale
48
+ this_locale = I18n.locale if default_translation_available
49
+ # If false, return default_locale
50
+ this_locale = I18n.default_locale unless default_translation_available
51
+ end
52
+
53
+ this_locale
54
+ end
55
+
56
+ def t_lang(content, options = {})
57
+ locale = t_locale(content, options)
58
+ "lang=#{locale}" unless locale.eql?(I18n.locale)
59
+ end
60
+
61
+ def t_locale_check(locale)
62
+ locale.presence unless locale.to_s.eql?(I18n.locale.to_s)
63
+ end
64
+
65
+ private
66
+
67
+ def translation_present?(content)
68
+ default_string = "This is a string to act as a default for the `I18n.translate` method. Comparing the result reveals if there is a translation in the i18n files."
69
+ I18n.translate(
70
+ content,
71
+ default: default_string,
72
+ fallback: false,
73
+ ) != default_string
74
+ end
33
75
  end
34
76
  end
35
77
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "23.7.1".freeze
2
+ VERSION = "23.7.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 23.7.1
4
+ version: 23.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-20 00:00:00.000000000 Z
11
+ date: 2020-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config