Well, more like translator experience rather than DX, but I would like to propose that we introduce some basic markdown support in t()
, to reduce the amount of HTML tags in our translatable strings, and make them shorter at the same time. I thought that it would be nice to support something that is popular in documentation writing, such as markdown style.
t()
allows for @
, %
, and !
for variable "placeholders" within the translatable string. Although @
and !
are special in that they respectively pass the text trough check_plain()
or not, %
is basically the same as @
, with the only difference being that it also wraps the text in <em>
when rendered.
%
seems to have been arbitrarily selected at a time when no other popular format was around, and is kinda "develop-y" if you ask me. With markdown being such popular in the documentation world, I would like to propose supporting the following in t()
:
*
: works exactly the same as%
, wrapping the text around<em>
. We still keep%
for backwards compatibility.**
: works the same as%
, but wraps the text around<strong>
instead of<em>
.***
: works the same as%
, but wraps the text around both<strong>
and<em>
.`
(back-tick): works the same as%
, but wraps the text around<code>
instead of<em>
.
So instead of this:
backdrop_set_message(t('Here is something in %italics.', array('%italics' => $some_text)), 'info');
backdrop_set_message(t('Here is something in <strong>@bold</strong>.', array('@bold' => $some_text)), 'info');
backdrop_set_message(t('Here is something in <strong><em>@bold_and_italics</em></strong>.', array('@bold_and_italics' => $some_text)), 'info');
backdrop_set_message(t('Here is some <code>@code</code>.', array('@code' => $some_code)), 'info');
...we could be doing this, which I believe is both shorter and easier for translators (especially the ones already familiar with markdown):
backdrop_set_message(t('Here is something in *@italics*.', array('@italics' => $some_text)), 'info');
backdrop_set_message(t('Here is something in **@bold**.', array('@bold' => $some_text)), 'info');
backdrop_set_message(t('Here is something in ***@bold_and_italics***.', array('@bold_and_italics' => $some_text)), 'info');
backdrop_set_message(t('Here is some `@code`.', array('@code' => $some_code)), 'info');
Advocate for this feature: @klonos
Recent comments
Loved the early concerns and upgradations of these days! This was much awaited by everyone in those days!
Official Core Initiative: Telemetry
I can confirm that I attempted to install this (UserPoints module) on a fresh site and got a fatal (white screen) error. Checking to see if we can unpublish this module from backdropcms...
Points for users
Uh oh :) You may want to report the exact errors in the queue. Who knows, maybe the maintainer will pick it up.
Points for users