Jump to content

How to change Font-Family according to language/locale?


!Joseph!

Recommended Posts

Hello Everyone,

This is my 1st post to the community and sincerely appreciate for the your help:)

Actually I'm running on a WHMCS site with English & Chinese (& I've removed all other language). For better user experience, I would like to match the font-family of my main webpage which also in Eng & Chi.

My question is how to change WHMCS font-family according to the language selected (english.php & chinese.php)? For English, I want to use Google fonts "Poppins", while for Chinese I would like to use "Microsoft JhengHei" (P.S. JhengHei a Win10/7 system fonts for Chinese).

I believe it's something about Hook & Custom CSS, but I've search around the community and got no idea how to do that......

Really appreciate again for your help!

 

Cheers,

Joe

 

Link to comment
Share on other sites

Hi Joe,

it would be something along the lines of...

<?php

function language_css_hook($vars) {
	
	if ($vars['language'] == "chinese") {
		return '<link href="'.$vars['WEB_ROOT'].'/templates/'.$vars['template'].'/css/custom-chinese.css" rel="stylesheet" type="text/css" />';
	}
	else {
		return '<link href="//fonts.googleapis.com/css?family=Poppins" rel="stylesheet">
		<link href="'.$vars['WEB_ROOT'].'/templates/'.$vars['template'].'/css/custom-english.css" rel="stylesheet" type="text/css" />';
	}
}
add_hook("ClientAreaHeadOutput", 1, "language_css_hook");
?>

so if the language selected is "Chinese", it will load a custom-chinese.css file from your active template/css folder (e.g templates/six/css/) - in which you can add all of your font changes (there might be a lot!).

for any other language, it loads the "Poppins" font and then a custom-english.php css file... i'm tempted to think you could drop the entire else part of the hook, and use the existing custom.css file for non-chinese languages, but to keep things clean, i've kept it calling one of two unique css files.

one other thing to note - you say that you've removed the other languages (which I assume means you've deleted the files from the /lang/ folder) - just be aware that if you run the WHMCS automatic updater and upgrade to a newer version of WHMCS, it will add those deleted languages back... obviously, if you are manually updating, you can decide not to restore those missing languages.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated