govuk_publishing_components 35.13.2 → 35.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (21) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +2 -2
  3. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +24 -5
  4. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +4 -5
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +1 -1
  6. data/app/views/govuk_publishing_components/components/_attachment.html.erb +5 -1
  7. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +30 -2
  8. data/app/views/govuk_publishing_components/components/_devolved_nations.html.erb +15 -1
  9. data/app/views/govuk_publishing_components/components/_emergency_banner.html.erb +18 -1
  10. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +2 -2
  11. data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +17 -1
  12. data/app/views/govuk_publishing_components/components/docs/cards.yml +2 -2
  13. data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +5 -0
  14. data/app/views/govuk_publishing_components/components/docs/devolved_nations.yml +16 -0
  15. data/app/views/govuk_publishing_components/components/docs/emergency_banner.yml +10 -0
  16. data/app/views/govuk_publishing_components/components/docs/phase_banner.yml +8 -0
  17. data/app/views/layouts/govuk_publishing_components/application.html.erb +1 -1
  18. data/config/locales/en.yml +2 -2
  19. data/lib/govuk_publishing_components/presenters/devolved_nations_helper.rb +16 -4
  20. data/lib/govuk_publishing_components/version.rb +1 -1
  21. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d89a426d686fe0891582f8851ff7b27c57a457b838dccd81aa07a4868a9a9975
4
- data.tar.gz: b267048c6e6bd91689fcedbad4e16835de62ff50aee68e94684ec4533ad7c5ab
3
+ metadata.gz: 999c5822c246101234a2c8d42828e3ee8b17df824b0472c12b55df5c2d81c4be
4
+ data.tar.gz: e6d08b1e863e2ded1152342176e3e7c506f3a89baf06a1c3b2b45c7c73c46ce0
5
5
  SHA512:
6
- metadata.gz: 9dcd81b321da508d0475825320afa9674bfbac1bf1ef73f5ce32ccd66d0f5225e08b569a9819ca34672c13e919e154e02570b51109613e53d9bc79945a0f3482
7
- data.tar.gz: 24bf0744fc140a4644c5b12d0de816869298a1927a25e3b1e126d0644b4bae78cd6ae5409d194e48465429e049517440321d39b12edd1ee783e717f54446659f
6
+ metadata.gz: 6fe723d3ea44de844e2228dbbbcfa815148df3b96b94edb58acba736815ab6f92142bf5f3853d0da0d2bca8f730f765414ea7d1c05db738d18c830bfadc88235
7
+ data.tar.gz: c06d8fbd16d112658797943def5f8b817f5c2c7e0424381cf16e8fb5c920d47a4ed8e88411be7509793da277f0f2d2f609765b6eb37d49550352b19be310d10b
@@ -169,10 +169,10 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
169
169
  removeCrossDomainParams: function (href) {
170
170
  if (href.indexOf('_ga') !== -1 || href.indexOf('_gl') !== -1) {
171
171
  // _ga & _gl are values needed for cross domain tracking, but we don't want them included in our click tracking.
172
- href = href.replaceAll(/_g[al]=([^&]*)/g, '')
172
+ href = href.replace(/_g[al]=([^&]*)/g, '')
173
173
 
174
174
  // The following code cleans up inconsistencies such as gov.uk/&&, gov.uk/?&hello=world, gov.uk/?, and gov.uk/&.
175
- href = href.replaceAll(/(&&)+/g, '&')
175
+ href = href.replace(/(&&)+/g, '&')
176
176
  href = href.replace('?&', '?')
177
177
  if (this.stringEndsWith(href, '?') || this.stringEndsWith(href, '&')) {
178
178
  href = href.substring(0, href.length - 1)
@@ -17,7 +17,7 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
17
17
  location: this.getLocation(),
18
18
  /* If the init() function receives a referrer parameter, this indicates that it has been called as a part of an AJAX request and
19
19
  this.getReferrer() will not return the correct value. Therefore we need to rely on the referrer parameter. */
20
- referrer: referrer ? this.PIIRemover.stripPIIWithOverride(referrer, true, true) : this.getReferrer(),
20
+ referrer: this.getReferrer(referrer),
21
21
  title: this.getTitle(),
22
22
  status_code: this.getStatusCode(),
23
23
 
@@ -53,7 +53,11 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
53
53
  /* The existence of a referrer parameter indicates that the page has been dynamically updated via an AJAX request
54
54
  and therefore we can use it to set the dynamic property appropriately. This value is used by PA's to differentiate
55
55
  between fresh page loads and dynamic page updates. */
56
- dynamic: referrer ? 'true' : 'false'
56
+ dynamic: referrer ? 'true' : 'false',
57
+ emergency_banner: document.querySelector('[data-ga4-emergency-banner]') ? 'true' : undefined,
58
+ phase_banner: this.getElementAttribute('data-ga4-phase-banner') || undefined,
59
+ devolved_nations_banner: this.getElementAttribute('data-ga4-devolved-nations-banner') || undefined,
60
+ cookie_banner: document.querySelector('[data-ga4-cookie-banner]') ? 'true' : undefined
57
61
  }
58
62
  }
59
63
  window.GOVUK.analyticsGa4.core.sendData(data)
@@ -61,11 +65,19 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
61
65
  },
62
66
 
63
67
  getLocation: function () {
64
- return this.PIIRemover.stripPII(document.location.href)
68
+ return this.PIIRemover.stripPII(this.stripGaParam(document.location.href))
65
69
  },
66
70
 
67
- getReferrer: function () {
68
- return this.PIIRemover.stripPIIWithOverride(document.referrer, true, true)
71
+ getReferrer: function (referrer) {
72
+ referrer = this.stripGaParam(referrer || document.referrer)
73
+ return this.PIIRemover.stripPIIWithOverride(referrer, true, true)
74
+ },
75
+
76
+ // remove GA parameters of the form _ga=2320.021-012302 or _gl=02.10320.01230-123
77
+ stripGaParam: function (str) {
78
+ str = str.replace(/(_ga=[0-9.-]+)/g, '_ga=[id]')
79
+ str = str.replace(/(_gl=[0-9.-]+)/g, '_gl=[id]')
80
+ return str
69
81
  },
70
82
 
71
83
  getTitle: function () {
@@ -91,6 +103,13 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
91
103
  }
92
104
  },
93
105
 
106
+ getElementAttribute: function (attributeName) {
107
+ var el = document.querySelector('[' + attributeName + ']')
108
+ if (el) {
109
+ return el.getAttribute(attributeName)
110
+ }
111
+ },
112
+
94
113
  getLanguage: function () {
95
114
  var content = document.getElementById('content')
96
115
  if (content) {
@@ -4,7 +4,6 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
4
4
  (function (Modules) {
5
5
  function CookieBanner ($module) {
6
6
  this.$module = $module
7
- this.$module.cookieBanner = document.querySelector('.gem-c-cookie-banner')
8
7
  this.$module.cookieBannerConfirmationMessage = this.$module.querySelector('.gem-c-cookie-banner__confirmation')
9
8
  this.$module.cookieBannerConfirmationMessageText = this.$module.querySelector('.gem-c-cookie-banner__confirmation-message')
10
9
  }
@@ -100,16 +99,16 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
100
99
  }
101
100
 
102
101
  CookieBanner.prototype.showConfirmationMessage = function () {
103
- this.$cookieBannerHeader = document.querySelector('.govuk-cookie-banner__heading')
102
+ this.$cookieBannerHeader = this.$module.querySelector('.govuk-cookie-banner__heading')
104
103
  this.$cookieBannerHeader.hidden = true
105
104
 
106
- this.$cookieBannerMainContent = document.querySelector('.gem-c-cookie-banner__content')
105
+ this.$cookieBannerMainContent = this.$module.querySelector('.gem-c-cookie-banner__content')
107
106
  this.$cookieBannerMainContent.hidden = true
108
107
 
109
- this.$cookieBannerConfirmationButtons = document.querySelector('.js-confirmation-buttons')
108
+ this.$cookieBannerConfirmationButtons = this.$module.querySelector('.js-confirmation-buttons')
110
109
  this.$cookieBannerConfirmationButtons.hidden = true
111
110
 
112
- this.$cookieBannerHideButton = document.querySelector('.js-hide-button')
111
+ this.$cookieBannerHideButton = this.$module.querySelector('.js-hide-button')
113
112
  this.$cookieBannerHideButton.hidden = false
114
113
  }
115
114
 
@@ -693,7 +693,7 @@ $after-button-padding-left: govuk-spacing(4);
693
693
  }
694
694
  }
695
695
 
696
- .gem-c-layout-super-navigation-header__navigation-second-items--topics {
696
+ .gem-c-layout-super-navigation-header__navigation-second-items--services-and-information {
697
697
  @include govuk-media-query($until: "desktop") {
698
698
  border-bottom: 1px solid govuk-colour("mid-grey");
699
699
  }
@@ -11,6 +11,7 @@
11
11
 
12
12
  container_class_names = %w[gem-c-attachment govuk-!-display-none-print]
13
13
  container_class_names << shared_helper.get_margin_bottom if local_assigns.key?(:margin_bottom)
14
+ ga4_link = { 'event_name': 'navigation', 'type': 'attachment' }
14
15
 
15
16
  case attachment.type
16
17
  when "file"
@@ -38,6 +39,9 @@
38
39
  class: "gem-c-attachment__attribute",
39
40
  )
40
41
  end
42
+
43
+ ga4_link[:event_name] = 'file_download'
44
+
41
45
  when "html"
42
46
  attributes << tag.span(
43
47
  "HTML",
@@ -51,7 +55,7 @@
51
55
  end
52
56
 
53
57
  %>
54
- <%= tag.section class: class_names(container_class_names), data: { module: "ga4-link-tracker", ga4_track_links_only: "", ga4_link: { 'event_name': 'navigation', 'type': 'attachment' } } do %>
58
+ <%= tag.section class: class_names(container_class_names), data: { module: "ga4-link-tracker", ga4_track_links_only: "", ga4_link: ga4_link } do %>
55
59
  <%= tag.div class: "gem-c-attachment__thumbnail" do %>
56
60
  <%= link_to attachment.url,
57
61
  class: "govuk-link",
@@ -30,6 +30,8 @@
30
30
  services_cookies ||= nil
31
31
  css_classes = %w(gem-c-cookie-banner govuk-clearfix govuk-cookie-banner js-banner-wrapper)
32
32
  css_classes << "gem-c-cookie-banner--services" if services_cookies
33
+
34
+ ga4_tracking ||= false
33
35
  %>
34
36
 
35
37
  <div id="<%= id %>" class="<%= css_classes.join(' ') %>" data-module="cookie-banner" data-nosnippet role="region" aria-label="<%= title %>">
@@ -39,7 +41,14 @@
39
41
  <h2 class="govuk-cookie-banner__heading govuk-heading-m"><%= title %></h2>
40
42
  <div tabindex="-1" class="govuk-cookie-banner__content gem-c-cookie-banner__confirmation">
41
43
  <span class="gem-c-cookie-banner__content"><%= text %></span>
42
- <p class="gem-c-cookie-banner__confirmation-message--accepted govuk-body" hidden><%= t("components.cookie_banner.confirmation_message.accepted") %>. <span class="gem-c-cookie-banner__confirmation-message"><%= confirmation_message %></span></p>
44
+ <p class="gem-c-cookie-banner__confirmation-message--accepted govuk-body" hidden
45
+ <% if ga4_tracking %>
46
+ data-ga4-cookie-banner <%# GA4 pageview JS looks for data-ga4-cookie-banner %>
47
+ data-module="ga4-link-tracker"
48
+ data-ga4-track-links-only
49
+ data-ga4-set-indexes
50
+ data-ga4-link="<%= { event_name: "navigation", type: "cookie banner", section: t("components.cookie_banner.confirmation_message.accepted", locale: :en) }.to_json %>"
51
+ <% end %>><%= t("components.cookie_banner.confirmation_message.accepted") %>. <span class="gem-c-cookie-banner__confirmation-message"><%= confirmation_message %></span></p>
43
52
  <p class="gem-c-cookie-banner__confirmation-message--rejected govuk-body" hidden><%= t("components.cookie_banner.confirmation_message.rejected") %>. <span class="gem-c-cookie-banner__confirmation-message"><%= confirmation_message %></span></p>
44
53
  </div>
45
54
  </div>
@@ -85,7 +94,26 @@
85
94
  <% end %>
86
95
  </div>
87
96
  <div hidden class="js-hide-button govuk-button-group">
88
- <button class="gem-c-cookie-banner__hide-button govuk-button" data-hide-cookie-banner="true" data-module="gem-track-click" data-track-category="cookieBanner" data-track-action="Hide cookie banner"><%= t("components.cookie_banner.hide") %></button>
97
+ <%
98
+ button_data_module = "gem-track-click"
99
+ button_data_module << " ga4-event-tracker" if ga4_tracking
100
+
101
+ ga4_event = {
102
+ event_name: "select_content",
103
+ type: "cookie banner",
104
+ action: "closed",
105
+ section: t("components.cookie_banner.confirmation_message.accepted", locale: :en)
106
+ }.to_json if ga4_tracking
107
+ %>
108
+ <button
109
+ class="gem-c-cookie-banner__hide-button govuk-button"
110
+ data-hide-cookie-banner="true"
111
+ data-module="<%= button_data_module %>"
112
+ data-track-category="cookieBanner"
113
+ data-track-action="Hide cookie banner"
114
+ <% if ga4_tracking %> data-ga4-event="<%= ga4_event %>" <% end %>>
115
+ <%= t("components.cookie_banner.hide") %>
116
+ </button>
89
117
  </div>
90
118
  </div>
91
119
  </div>
@@ -6,10 +6,24 @@
6
6
 
7
7
  applies_to ||= t("components.devolved_nations.applies_to")
8
8
  heading_level ||= 2
9
+ ga4_tracking ||= false
10
+ data_attributes = {}
11
+
12
+ if ga4_tracking
13
+ data_attributes[:ga4_devolved_nations_banner] = devolved_nations_helper.ga4_applicable_nations_title_text(true)
14
+ data_attributes[:module] = "ga4-link-tracker"
15
+ data_attributes[:ga4_track_links_only] = ""
16
+ data_attributes[:ga4_set_indexes] = ""
17
+ data_attributes[:ga4_link] = {
18
+ event_name: "navigation",
19
+ type: "devolved nations banner",
20
+ section: t("components.devolved_nations.applies_to", locale: :en) + " " + devolved_nations_helper.ga4_applicable_nations_title_text,
21
+ }.to_json
22
+ end
9
23
  %>
10
24
 
11
25
  <% if national_applicability.any? { |k,v| v[:applicable] == true } %>
12
- <%= tag.section class: "gem-c-devolved-nations" do %>
26
+ <%= tag.section class: "gem-c-devolved-nations", data: data_attributes do %>
13
27
  <%= content_tag(shared_helper.get_heading_level, class: "govuk-heading-s govuk-!-margin-bottom-0") do %>
14
28
  <%= applies_to %> <%= devolved_nations_helper.applicable_nations_title_text %>
15
29
  <% end %>
@@ -7,6 +7,7 @@
7
7
  link_text ||= "More information"
8
8
  campaign_class ||= nil
9
9
  homepage ||= false
10
+ ga4_tracking ||= false
10
11
 
11
12
  emergency_banner_helper = GovukPublishingComponents::Presenters::EmergencyBannerHelper.new()
12
13
 
@@ -28,9 +29,25 @@
28
29
  description_classes = %w[gem-c-emergency-banner__description]
29
30
  description_classes << "gem-c-emergency-banner__description--homepage" if homepage
30
31
 
32
+
33
+ data_attributes = {
34
+ "nosnippet": true,
35
+ }
36
+
37
+ if ga4_tracking
38
+ data_attributes[:ga4_emergency_banner] = ""
39
+ data_attributes[:module] = "ga4-link-tracker"
40
+ data_attributes[:ga4_track_links_only] = ""
41
+ data_attributes[:ga4_set_indexes] = ""
42
+ data_attributes[:ga4_link] = {
43
+ event_name: "navigation",
44
+ type: "emergency banner",
45
+ section: heading,
46
+ }.to_json
47
+ end
31
48
  %>
32
49
 
33
- <%= content_tag('section', class: banner_classes, "aria-labelledby": "emergency-banner-heading", "data-nosnippet": true ) do %>
50
+ <%= content_tag('section', class: banner_classes, "aria-labelledby": "emergency-banner-heading", data: data_attributes) do %>
34
51
  <div class="govuk-width-container">
35
52
  <div class="govuk-grid-row">
36
53
  <div class="govuk-grid-column-two-thirds">
@@ -217,11 +217,11 @@
217
217
  end
218
218
  %>
219
219
 
220
- <div class="<%= width_class %> gem-c-layout-super-navigation-header__column--<%= column[:label].downcase.sub(" ", "-") %>">
220
+ <div class="<%= width_class %> gem-c-layout-super-navigation-header__column--<%= column[:label].downcase.gsub(" ", "-") %>">
221
221
  <h3 class="govuk-heading-m gem-c-layout-super-navigation-header__column-header">
222
222
  <%= column[:label] %>
223
223
  </h3>
224
- <ul class="gem-c-layout-super-navigation-header__navigation-second-items gem-c-layout-super-navigation-header__navigation-second-items--<%= column[:label].downcase.sub(" ", "-") %>">
224
+ <ul class="gem-c-layout-super-navigation-header__navigation-second-items gem-c-layout-super-navigation-header__navigation-second-items--<%= column[:label].downcase.gsub(" ", "-") %>">
225
225
  <% index_total = column[:menu_contents].length %>
226
226
  <% column[:menu_contents].each_with_index do | item, index | %>
227
227
  <%
@@ -5,6 +5,7 @@ app_name ||= nil
5
5
  phase ||= nil
6
6
  message ||= nil
7
7
  inverse ||= false
8
+ ga4_tracking ||= false
8
9
 
9
10
  unless message.present?
10
11
  if phase == "beta"
@@ -16,9 +17,24 @@ end
16
17
 
17
18
  container_css_classes = %w(gem-c-phase-banner govuk-phase-banner)
18
19
  container_css_classes << "gem-c-phase-banner--inverse" if inverse
20
+
21
+ data_attributes = {}
22
+
23
+ if ga4_tracking
24
+ data_attributes[:ga4_phase_banner] = phase
25
+ data_attributes[:module] = "ga4-link-tracker"
26
+ data_attributes[:ga4_track_links_only] = ""
27
+ data_attributes[:ga4_set_indexes] = ""
28
+ data_attributes[:ga4_link] = {
29
+ event_name: "navigation",
30
+ type: "phase banner",
31
+ section: Nokogiri::HTML(message).text,
32
+ }.to_json
33
+ end
34
+
19
35
  %>
20
36
 
21
- <%= tag.div class: container_css_classes do %>
37
+ <%= tag.div class: container_css_classes, data: data_attributes do %>
22
38
  <%= tag.p class: "govuk-phase-banner__content" do %>
23
39
  <%= tag.strong app_name, class: "govuk-phase-banner__content__app-name" if app_name %>
24
40
  <%= tag.strong phase, class: "govuk-tag govuk-phase-banner__content__tag" if phase %>
@@ -20,7 +20,7 @@ uses_component_wrapper_helper: true
20
20
  examples:
21
21
  default:
22
22
  data:
23
- heading: Topics
23
+ heading: Services and information
24
24
  items:
25
25
  - link:
26
26
  text: Benefits
@@ -109,7 +109,7 @@ examples:
109
109
 
110
110
  Override default subheading level by passing through `sub_heading_level` parameter (defaults to `<h3>`)
111
111
  data:
112
- heading: Topics
112
+ heading: Services and information
113
113
  heading_level: 3
114
114
  sub_heading_level: 4
115
115
  items:
@@ -49,3 +49,8 @@ examples:
49
49
  cookie_preferences:
50
50
  text: How we use cookies
51
51
  href: "/cookies"
52
+ with_ga4_tracking:
53
+ description: |
54
+ Enables GA4 tracking on the banner. This includes link tracking on the "You have accepted cookies" section, and allows the pageview event that is sent when GA4 initialises to record the presence of the cookie acceptance message.
55
+ data:
56
+ ga4_tracking: true
@@ -89,3 +89,19 @@ examples:
89
89
  national_applicability:
90
90
  england:
91
91
  applicable: true
92
+ with_ga4_tracking:
93
+ description: |
94
+ Enables GA4 tracking on the banner. This includes link tracking on the component itself, and allows pageviews to record the presence of the banner on page load.
95
+ data:
96
+ national_applicability:
97
+ england:
98
+ applicable: true
99
+ scotland:
100
+ applicable: true
101
+ wales:
102
+ applicable: true
103
+ northern_ireland:
104
+ applicable: false
105
+ alternative_url: /
106
+ type: detailed_guide
107
+ ga4_tracking: true
@@ -45,3 +45,13 @@ examples:
45
45
  short_description: "1491 to 1547"
46
46
  link: "https://www.gov.uk/"
47
47
  homepage: true
48
+ with_ga4_tracking:
49
+ description: |
50
+ Enables GA4 tracking on the banner. This includes link tracking on the component itself, and allows pageviews to record the presence of the banner on page load.
51
+ data:
52
+ campaign_class: "notable-death"
53
+ heading: "His Royal Highness Henry VIII"
54
+ short_description: "1491 to 1547"
55
+ link: "https://www.gov.uk/"
56
+ homepage: true
57
+ ga4_tracking: true
@@ -32,3 +32,11 @@ examples:
32
32
  app_name: Skittles Maker
33
33
  phase: beta
34
34
  inverse: true
35
+ with_ga4_tracking:
36
+ description: |
37
+ Enables GA4 tracking on the banner. This includes link tracking on the component itself, and allows pageviews to record the presence of the banner on page load.
38
+ data:
39
+ app_name: Skittles Maker
40
+ phase: beta
41
+ inverse: true
42
+ ga4_tracking: true
@@ -6,7 +6,7 @@
6
6
  <% else %>
7
7
  <%= render "govuk_publishing_components/components/layout_header", {
8
8
  environment: GovukPublishingComponents::AppHelpers::Environment.current_acceptance_environment,
9
- product_name: GovukPublishingComponents::Config.component_guide_title,
9
+ product_name: "#{GovukPublishingComponents::Config.component_guide_title} #{GovukPublishingComponents::VERSION}",
10
10
  href: component_guide_path
11
11
  } %>
12
12
  <div class="govuk-width-container app-width-container--wide">
@@ -91,7 +91,7 @@ en:
91
91
  copyright_html: <a class="govuk-footer__link govuk-footer__copyright-logo" href="https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/">© Crown copyright</a>
92
92
  licence_html: All content is available under the <a class="govuk-footer__link" href="https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" rel="license">Open Government Licence v3.0</a>, except where otherwise stated
93
93
  navigation_links:
94
- - title: Topics
94
+ - title: Services and information
95
95
  menu_contents:
96
96
  - text: Benefits
97
97
  href: "/browse/benefits"
@@ -171,7 +171,7 @@ en:
171
171
  href: "/browse"
172
172
  label: Menu
173
173
  navigation_links_columns:
174
- - label: Topics
174
+ - label: Services and information
175
175
  size: 2
176
176
  menu_contents:
177
177
  - label: Benefits
@@ -8,17 +8,29 @@ module GovukPublishingComponents
8
8
  @type = local_assigns[:type] || "publication"
9
9
  end
10
10
 
11
- def applicable_nations_title_text
11
+ def applicable_nations_title_text(use_english_translation = nil)
12
12
  @national_applicability
13
13
  .select { |_, v| v[:applicable] == true }
14
- .map { |k, _| I18n.t("components.devolved_nations.#{k}") }
14
+ .map { |k, _| get_translation("components.devolved_nations.#{k}", use_english_translation) }
15
15
  .sort
16
16
  .to_sentence(
17
- two_words_connector: I18n.t("components.devolved_nations.connectors.two_words"),
18
- last_word_connector: I18n.t("components.devolved_nations.connectors.last_word"),
17
+ two_words_connector: get_translation("components.devolved_nations.connectors.two_words", use_english_translation),
18
+ last_word_connector: get_translation("components.devolved_nations.connectors.last_word", use_english_translation),
19
19
  )
20
20
  end
21
21
 
22
+ def get_translation(key, use_english_translation = nil)
23
+ return I18n.t(key, locale: :en) if use_english_translation
24
+
25
+ I18n.t(key)
26
+ end
27
+
28
+ def ga4_applicable_nations_title_text(remove_connector_word = nil)
29
+ return applicable_nations_title_text(true).gsub(" and", ",") if remove_connector_word
30
+
31
+ applicable_nations_title_text(true)
32
+ end
33
+
22
34
  def nations_with_urls
23
35
  @national_applicability
24
36
  .select do |_, v|
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "35.13.2".freeze
2
+ VERSION = "35.15.0".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: 35.13.2
4
+ version: 35.15.0
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: 2023-08-15 00:00:00.000000000 Z
11
+ date: 2023-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -1468,7 +1468,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1468
1468
  - !ruby/object:Gem::Version
1469
1469
  version: '0'
1470
1470
  requirements: []
1471
- rubygems_version: 3.4.18
1471
+ rubygems_version: 3.4.19
1472
1472
  signing_key:
1473
1473
  specification_version: 4
1474
1474
  summary: A gem to document components in GOV.UK frontend applications