根据 Drupal 7 中的语言切换样式

Switching the Style depending on the language in Drupal 7

我想根据语言更改样式。例如,当我将站点语言切换为阿拉伯语时,我希望我编写的 rtl 样式生效,并在切换回英语时取消设置 rtl 样式。如何在 Drupal 7 中实现这一点? 我试过这个 answer 但对我没用。

最简单的方法是使用语言 class Drupal 正在添加到 body 元素。检查您的页面 html 并查看 classes body 标签有什么。应该有一些 class 类似于 "i18n-de" (在这种情况下是德语)。然后你可以使用它来为 body 标签内的任何元素(基本上所有元素)设置不同的样式,例如:

body.i18n-de div#header {.some css.}
body.i18n-en div#header {.some other css.}