Sha256: 9c844a1f583809aaa4ac10c028a820d09bf4d0d5fccba068ff38ed4c4a66e8e5

Contents?: true

Size: 1001 Bytes

Versions: 63

Compression:

Stored size: 1001 Bytes

Contents

{#
  Renders translated text into data attributes by translation key

  - Provide params.message for translation text, singular
  - Provide params.messages for translation text by corresponding plural rule

  {@link https://cldr.unicode.org/index/cldr-spec/plural-rules}

  Helps reduce the boilerplate in component templates as they're quite verbose

  @private
  @param {object} params - i18n macro params
  @param {string} params.key - Translation key (kebab-case)
  @param {string} [params.message] - Translation text, singular
  @param {{ [pluralRule: string]: string }} [params.messages] - Translation text by corresponding plural rule (optional, overrides params.message)
#}
{% macro govukI18nAttributes(params) %}
  {%- if params.messages -%}
    {% for pluralRule, message in params.messages %} data-i18n.{{ params.key }}.{{ pluralRule }}="{{ message | escape }}"{% endfor %}
  {% elseif params.message %} data-i18n.{{ params.key }}="{{ params.message | escape }}"{% endif -%}
{% endmacro %}

Version data entries

63 entries across 63 versions & 2 rubygems

Version Path
govuk_publishing_components-44.2.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-44.1.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-44.0.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-43.5.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-43.4.1 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-43.4.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-43.3.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-43.2.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-43.1.1 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-43.1.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-43.0.2 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-43.0.1 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-43.0.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-42.1.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-42.0.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-41.1.2 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-41.1.1 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-41.1.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-41.0.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-40.1.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk