Skip to content
GitLab
Next
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 44,763
    • Issues 44,763
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,330
    • Merge requests 1,330
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLabGitLab
  • Issues
  • #217935
Closed
Open
Issue created May 15, 2020 by Josianne Hyson@jhyson💡Developer1 of 3 checklist items completed1/3 checklist items

Add translation helper for using HTML tags in externalized strings

This issue is intended to address part of https://gitlab.com/gitlab-org/gitlab/-/issues/19485

It is the follow up issue to https://gitlab.com/gitlab-org/gitlab/-/issues/217933 where we disallowed HTML tags in externalized strings.

Goals

  1. To introduce a ruby externalization helper that will allow developers to use basic HTML tags without submitting them for translation
  2. To introduce a similar helper for javascript externalization
  3. Update any existing strings to use these helpers
  4. Update documentation and communicate changes to the dev team if necessary

Planned Approach:

Basic Usage:

html_(s_("Namespace|Example string with some %{strongTagOpen}strong%{strongTagClose} text"))
# => 'Example string with some <strong>strong</strong> text'

The html_() method can substitute in the <strong> tags (and a small set of accepted tags) by default. It will also call html_escape (or equivalent in js) to ensure that the string does not contain unescaped characters.

Usage with attributes:

For examples where we need additional attributes we could have tag generator helpers, like described in: https://gitlab.com/gitlab-org/gitlab/-/issues/19485#note_215045602

zones_link_info = translated_link_to("zones", zones_path, class: 'btn')
 # => { 'zones_link_start' => '<a href="/zones" class="btn">', 'zones_link_end' => '</a>' }

# And can be used as:
_("Learn more about %{zone_link_start}zones%{zone_link_end}") % zone_link_info

Action Items

  • Validate the solution we'd like to approach on the backend
  • Do a spike to make sure the approach is also feasible on the frontend
  • Based on the results, determine if both issues can be scheduled and ready for development in %13.1.
Edited Jun 16, 2020 by Josianne Hyson
Assignee
Assign to
Time tracking