Solved

Define different fonts for different languages

Posted on 2014-02-05
8
395 Views
Last Modified: 2014-02-19
My site is using 3.8.1 Wordpress, and it is multilangual site (Some pages are English, some Dutch, and some Arabic).
Is it possible to assign to different font families to different languages?
I have tried to add an import at the end of the style.css for the arabic font but it has cancelled the English font, is it possible to solve it?
0
Comment
Question by:Ashraf Hassanein
  • 3
  • 3
  • 2
8 Comments
 
LVL 28

Expert Comment

by:chilternPC
ID: 39837238
I would have a style sheet (style.css) for each language and then place it where you choose which language.
it really depends on what plugin or method you use to switch languages
0
 
LVL 15

Accepted Solution

by:
eemit earned 500 total points
ID: 39837253
Try this in your child theme functions.php:

/**
 * Enqueues scripts and styles for front-end.
 *
 */
add_action( 'wp_enqueue_scripts', 'yourchildthemeprefix_scripts_styles', 11 );
function yourchildthemeprefix_scripts_styles() {

	/*
	 * Loads our main stylesheet.
	 */
	wp_enqueue_style( 'yourchildthemeprefix-style', get_stylesheet_directory_uri() . '/style.css', array(), '20140205' );

	// If it is a multisite use this
	//$blog_language = get_bloginfo('language');
	//if ( $blog_language == "de-DE" ) {
	// If it is not a multisite use this
	if ( is_page( 'your-page-slug-whith-de' )  )     {
		wp_enqueue_style( 'yourchildthemeprefix-de', get_stylesheet_directory_uri() . '/css/de.css', array( 'yourchildthemeprefix-style' ), '20140205' );
	} else {
		wp_enqueue_style( 'yourchildthemeprefix-en', get_stylesheet_directory_uri() . '/css/en.css', array( 'yourchildthemeprefix-style' ), '20140205' );
	}
}

Open in new window


Adapt it to your languages and your pages.
0
 

Author Comment

by:Ashraf Hassanein
ID: 39842109
But do I need to append the page names with the languages? Also do I need to put in the de.css and en.css only the font or every thing in the style.css?
0
 
LVL 28

Expert Comment

by:chilternPC
ID: 39842136
not sure I understand    "But do I need to append the page names with the languages? "
you say you have pages in different languages, so I would create a style sheet for each language and in those style sheets have the changes you want for than language.
then put those style sheets in the place where the language is chosen.
depends on what multi lingual plug in you are using.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 28

Expert Comment

by:chilternPC
ID: 39842174
in your header.php (after the inclusion of style.css) you could add this code:

$mylanguage = get_bloginfo('language');
if($mylanguage == 'en-US') {
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/enstyle.css" media="screen" type="text/css" />
}
elseif($mylanguage == 'fr-FR'){
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/frstyle.css" media="screen" type="text/css" />
}
0
 

Author Comment

by:Ashraf Hassanein
ID: 39842220
I am very very sorry for my stupid question,  my website currently has both Arabic and English
In the navigation menu I have in one menu items in English and the items in Arabic, how the the wordpress will now which font to use for each item? does it detect the character set?
0
 
LVL 15

Expert Comment

by:eemit
ID: 39842455
But do I need to append the page names with the languages
No you don't need  to append the page names e.g.
is_page( 'here-only-your-page slug' )
The same for wp_enqueue_style e.g.:
wp_enqueue_style( 'here-only-your-unic-name-for-style',

Also do I need to put in the de.css and en.css only the font or every thing in the style.css?

Only the font.

You don't need  to change your header.php

Put your language css files in css subfolder in your child theme.
Yuo don't need any language code in your css file names.
0
 

Author Comment

by:Ashraf Hassanein
ID: 39872633
Finally I managed to implement different fonts for different languages.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now