[csswg-drafts] [css-variables] Example 5 might not represent best practices (#7130)

aphillips has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-variables] Example 5 might not represent best practices ==
(See Example 5)
https://www.w3.org/TR/css-variables-1/#defining-variables

> A real-world example of [custom property](https://www.w3.org/TR/css-variables-1/#custom-property) usage is easily separating out strings from where they’re used, to aid in maintenance of internationalization:
```
:root,
:root:lang(en) {--external-link: "external link";}
:root:lang(de) {--external-link: "externer Link";}

a[href^="http"]::after {content: " (" var(--external-link) ")"}
```
> The variable declarations can even be kept in a separate file, to make maintaining the translations simpler.

This is perhaps questionable advice? On the one hand, if one has static strings in one's style sheet, using a variable and the `:lang` selector might be useful as a way of localizing the strings without repetition. On the other hand, there is some complexity to language matching here and it's probably not a best practice to have strings embedded in this way anyway. Our (I18N's) comment here might be "we wish you'd picked another example"

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7130 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 10 March 2022 17:35:55 UTC