Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

341
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda