Skip to content

Commit e6e2164

Browse files
committed
Add real-world example of using custom properties with :lang.
1 parent 7c5e24c commit e6e2164

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

css-variables/Overview.bs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,24 @@ Custom Property Value Syntax</h3>
240240
</pre>
241241
</div>
242242

243+
<div class='example'>
244+
A real-world example of <a>custom property</a> usage
245+
is easily separating out strings from where they're used,
246+
to aid in maintenance of internationalization:
247+
248+
<pre class='lang-css'>
249+
:root,
250+
:root:lang(en) {--external-link: "external link";}
251+
:root:lang(de) {--external-link: "externer Link";}
252+
253+
a[href^="http"]::after {content: " (" var(--external-link) ")"}
254+
</pre>
255+
256+
The variable declarations can even be kept in a separate file,
257+
to make maintaining the translations simpler.
258+
</div>
259+
260+
243261

244262
<h3 id='cycles'>
245263
Resolving Dependency Cycles</h3>

0 commit comments

Comments
 (0)