The English Wikipedia has templates such as {{lang-fr}}, which put text into <span lang="fr"> tags. This is useful in every page that involves text in any foreign language, and since there are so many such articles in wiki sites in all languages, such templates are useful everywhere. At the moment, however, they have to be recreated in every wiki separately because we don't have global templates.
Plain HTML could be used, in theory, but actually it's not so good for several not-necessarily-obvious reasons:
- It's longer to type.
- It would be useful to deduce the default direction (dir attribute: ltr or rtl) from the language. HTML cannot do this, and writing it manually every time is inconvenient.
- The lang and dir attributes work differently in different browsers. In particular, current versions of Firefox and Chrome implement automatic bidirectional isolation for every tag that has a dir attribute, so there's no need for RLM/LRM characters, unicode-bidi: isolate CSS, or a <bdi> tag. Microsoft Internet Explorer and Edge, however, don't seem to implement isolation, even though it has been specified in the HTML standard in one way or another since 2011, so they also need RLM/LRM characters to ensure correct display. Some day when these browsers become old and rare it will be possible to remove these no-longer-necessary control characters and use only pure language semantics, and it would be nice to be prepared for that by making their application centralized.
How exactly should it be implemented? One option is an extension with implementation of these templates as Lua modules, so they would be essentially global. Another option is adding a parser function, similarly to the Babel extension, although I am more inclined to the Lua option, because it will be an easier transition from the current implementation as a template.