Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

336
Views
How to manage two different font files when language changes

I have a vue application that is multi-language (which for that I used i18n) and I need to handle the font-family for each language in different css file.

I had an idea that I can import css files conditionally but I don't know how.

Does anybody else have any idea or solution for my problem?

There are two different css file like this and each render different font from other:

@font-face {
  font-family: "Questrial";
  src: url("../../fonts/Questrial-Regular.ttf");
}

@font-face {
  font-family: "Galano_Grotesque_extra_Bold";
  src: url("../../fonts/Galano_Grotesque_Bold.otf");
}

@font-face {
  font-family: "Galano_Grotesque_Bold";
  src: url("../../fonts/Galano_Grotesque_DEMO_Bold.otf");
}

If I want to say that in other word, my application has "English" and "Persian" language. When app locale is English I need to render en-css.css file and when the locale is Persian I need to render fa-css.css file.

I would be glad to hear about your ideas :)

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You could use your html-tags lang attribute to overwrite the used font-family on your html tag according to your applications language.

@font-face {
  font-family: "Questrial";
  src: url("../../fonts/Questrial-Regular.ttf");
}

@font-face {
  font-family: "Galano_Grotesque_extra_Bold";
  src: url("../../fonts/Galano_Grotesque_Bold.otf");
}

@font-face {
  font-family: "Galano_Grotesque_Bold";
  src: url("../../fonts/Galano_Grotesque_DEMO_Bold.otf");
}


/* english font default */

html {
  font-family: "Questrial";
}


/* other font for persian */

html[lang="fa"] {
  font-family: "Galano_Grotesque_Bold";
}

over 4 years ago · Santiago Trujillo Report

0

Given that you can't change the lang attribute, you can use unicode-range in font definitions. For Languages using the basic Latin alphabet:

@font-face {
  font-family: "Questrial";
  src: url("../../fonts/Questrial-Regular.ttf");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

And for Persian (using Vazir as a sample Persian font),

@font-face {
  font-family: "Vazir";
  src: url("../../fonts/vazir.ttf");
  unicode-range: U+0660-0669, U+06F0-06F9;
}

The above Unicode ranges might need adjustments depending on your application requirements.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!