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-51.1.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-51.0.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-50.0.1 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-50.0.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-49.1.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-49.0.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-48.0.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-47.0.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-46.4.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-46.3.1 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-46.3.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-46.2.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-46.1.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-46.0.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-45.10.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-45.9.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-45.8.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-45.7.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-45.6.1 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk
govuk_publishing_components-45.6.0 node_modules/govuk-frontend/dist/govuk/macros/i18n.njk