Solved

Define different fonts for different languages

Posted on 2014-02-05
8
391 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 28

Expert Comment

by:chilternPC
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Finally I managed to implement different fonts for different languages.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
The viewer will learn how to count occurrences of each item in an array.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

743 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

8 Experts available now in Live!

Get 1:1 Help Now