Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

346
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda