Solved

Define different fonts for different languages

Posted on 2014-02-05
8
399 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
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: 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
 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

773 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