fatg
fatg

Reputation: 529

How to set font dynamically based on locale in rails?

I have a project with 3 different locales and I need to use another font for Vietnamese locale. Any ideas on how to achieve this?

Upvotes: 1

Views: 238

Answers (1)

DaniG2k
DaniG2k

Reputation: 4903

Within the template, you can change the font based on locale by simply using the locale name as a CSS selector, as follows:

<body class="<%= I18n.locale %>">
 ...
</body>

and in your SASS file:

body {
  .en {
    $main-font: "Verdana"
   }
  .cn {
    $main-font: "Microsoft_YaHei247019"
   }
}

Upvotes: 1

Related Questions