This simple patch attempts to add a class to the tag of every page based on the language in use as the page is rendered. The class name is the language code prefixed by "i18n-", so "i18n-en", "i18n-es", etc. This makes it trivial for themers to tweak the styling of the page depending on the language that is being used.

This idea was originally suggested as a patch for the Zen theme by user craigntammy in a post on the Zen Task Force group on G.d.o.

Unfortunately, this will not work with all themes, because not all themes respect the variable that this patch tweaks in order to achieve this. It looks like Zen and Fusion subthemes will work with no problem, but not Garland/Minelli… ouch!

CommentFileSizeAuthor
lang-class-to-body.patch679 bytesGarrett Albright

Comments

hass’s picture

+

jose reyero’s picture

Status: Needs review » Fixed

Looks like a good idea to me. Committed, thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sadist’s picture

Hi Garrett. Thanks for the patch.

Trying to use it for my own custom theme, I wonder how does it works actually? What I'm trying to achieve is for my theme, to only call a custom css file against the current language of the page.

So I place the file i18n-en and i18n-es (or other languages) in my theme directory and it will automatically call i18n-en if it's in English?

Garrett Albright’s picture

No, this patch does not include different CSS files for different languages. Instead, you can use a different selector on the <body> tag for the language you want to target. So, for example, to make text marked with the <strong> tag red, except for on Spanish pages where you want it to be blue…

strong {
  color: red;
}

body.i18n-es strong {
  color: blue;
}

Not a very practical example, but hopefully you get the idea.