Mark UI text with shortcodes and validate it against gitlab.pot
What this does
We currently mark UI text in the docs with Markdown bold, but bold is overloaded: people keep using it for emphasis (despite the our guidance to avoid it), and we also use it for UI text from other products. Translation tooling looks up UI strings in locale/gitlab.pot to reuse an already-translated string, and it has no way to tell which bold text is an actual GitLab label, or if missing strings are due to a typo or things getting out of sync.
Additionally, the UI text could be updated in the code at any time, and the docs very easily get out of sync.
Add shortcodes to mark UI text (gitlab-org/technical-writing/docs-gitlab-com!2601 - merged) introduces two shortcodes, {{< ui text=" " >}} for GitLab UI text and {{< external-ui text=" " >}} for UI text belonging to another product.
This MR:
- Makes use of the new shortcodes in one file to demonstrate both
uiandexternal-ui. - Adds a test that verifies every
uistring against thegitlab.potfile. It does not check UI text that still uses simple markdown bold. - Shows that UI text namespaces (
namespace|ui text) work and ensure the exact correct ui text string is checked in thegitlab.potfile.
Changes
-
doc/integration/jenkins.mdis the example page. It mixes GitLab UI text with Jenkins UI text, so it validates both shortcodes: 13 GitLab labels useui, and 37 Jenkins labels useexternal-ui. For example:1. On the Jenkins server, select {{< external-ui text="Manage Jenkins" >}} > {{< external-ui text="Manage Plugins" >}}. 1. In the left sidebar, select {{< ui text="Settings" >}} > {{< ui text="Integrations" >}}. -
scripts/lint/check_ui_text.rbis a new checker. It scans Markdown for theuishortcode and confirms every marked string exists as a msgid inlocale/gitlab.pot. It runs over all 2,939 files indoc/in about half a second, ignoringexternal-uishortcodes by design..gitlab/ci/docs.gitlab-ci.ymladds adocs-lint ui-textjob to run the check in CI/CD pipelines, making sure everything stays in sync.
-
lib/gitlab/help/hugo_transformer.rbensures both shortcodes render as bold in/help. Covered by new examples in the related spec. -
.vale.iniadds both shortcodes toTokenIgnoresso the markup isn't linted by vale.
Demo page findings
One label is deliberately left as plain bold, and one had drifted:
**Jenkins**, the name of the integration in GitLab's integration list. It's GitLab UI text, butapp/models/integrations/jenkins.rbline 73 returns the title as a plain hardcoded string with no translation call, so it will never be in the pot file. This stays as simple bold for now.**Secret Token**, the GitLab webhook field, was out of sync: the real label isWebhooks|Secret token (not recommended). Updated, but this also suggests the whole section might need to be revisited, or removed, if it's not a recommended feature anymore.
Findings from building the checker
One normalization rule turned out to be necessary:
- Some product labels end in an ellipsis in the UI but are documented without one. Docs say
Search or go to, but the pot msgid isSearch or go to…(U+2026). The checker strips a trailing ellipsis from both sides before comparing.
Sample failure output:
UI text not found in locale/gitlab.pot:
/tmp/neg.md:2: "This Is Definitely Not A Real Label"
/tmp/neg.md:3: "search or go to"The second line is a capitalization mismatch, not a missing string. The style guide requires UI text to match the label's case exactly, so the checker catches that too.
Preview
View of the updated Jenkins integration page:
-
Review app: Check the review app to see how it renders on the docs site: https://docs.gitlab.com/upstream-review-mr-ee-253587/integration/jenkins/
-
In
/help:Screenshot 
