Hello everyone,
I am working on a PHP script site that was originally written in English so all characters, words, images are set to appear from Left-to-Right by default.
I am trying to use this script in Persian Language where everything should appear in the opposite direction as in Persian Script writing starts from Right-to-Left.
Is there an easy way of doing this change in PHP? I am not sure if this is something that needs to be done on every single .php page or I can just add a line of code in the style.css file and be done.
Any help or feedback would be appreciated.
Convert to Right-to-Left
Moderator: General Moderators
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Convert to Right-to-Left
It's not determined by PHP, but by the HTML and the browser:
Change dir="ltr" and the charset and lang settings as appropriate
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-gb" xml:lang="en-gb">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-language" content="en-gb" />
Re: Convert to Right-to-Left
Mark Baker wrote:It's not determined by PHP, but by the HTML and the browser:
Change dir="ltr" and the charset and lang settings as appropriateCode: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-gb" xml:lang="en-gb"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="content-language" content="en-gb" />
Thanks for your reply.
Do I need to add the above codes into every php page? or just in the index.php will do?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Convert to Right-to-Left
You need the code to be *output* to the browser for every page. As to whether that means you need it in every .php page we don't know without seeing your code.
Wherever your <html> tags are output, that's where it needs to be.
Wherever your <html> tags are output, that's where it needs to be.
Re: Convert to Right-to-Left
Chris Corbyn wrote:You need the code to be *output* to the browser for every page. As to whether that means you need it in every .php page we don't know without seeing your code.
Wherever your <html> tags are output, that's where it needs to be.
Okay, I was able to move all contents to RTL. Now everything appears from Right to Left except for my Category Titles that is still LTR.
I noticed that in mysql database "Collation" shows "latin1_swedish_ci" in my phpmyadmin, I am not sure if this has anything to do with my issue or not. Should I change this setting to "utf8_general_ci"? is it risky to modify this setting in MySQL?
Right now my index.php page is set to output everything from Right to Left... any idea why the Category Lines are still LTR?
Thank You
- Attachments
-
- 1.JPG (18.07 KiB) Viewed 364 times
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Convert to Right-to-Left
Unlikely to be the cause of the problem with categories, but will affect sorting on text fields. I'd recommend changing the to utf-8. I don't thinks it's risky simply changing the collation, but can't guarantee it as I rarely use mySql.maximoox wrote:I noticed that in mysql database "Collation" shows "latin1_swedish_ci" in my phpmyadmin, I am not sure if this has anything to do with my issue or not. Should I change this setting to "utf8_general_ci"? is it risky to modify this setting in MySQL?
It's possible for style classes to override the language settings for the page, and these would apply to individual items on the page. I'd check the styles that you're using for your categories.maximoox wrote: Right now my index.php page is set to output everything from Right to Left... any idea why the Category Lines are still LTR?
Alternatively, if the page is using tables for layout, look for align="left" in the generated HTML
Re: Convert to Right-to-Left
Mark Baker wrote:Unlikely to be the cause of the problem with categories, but will affect sorting on text fields. I'd recommend changing the to utf-8. I don't thinks it's risky simply changing the collation, but can't guarantee it as I rarely use mySql.maximoox wrote:I noticed that in mysql database "Collation" shows "latin1_swedish_ci" in my phpmyadmin, I am not sure if this has anything to do with my issue or not. Should I change this setting to "utf8_general_ci"? is it risky to modify this setting in MySQL?
It's possible for style classes to override the language settings for the page, and these would apply to individual items on the page. I'd check the styles that you're using for your categories.maximoox wrote: Right now my index.php page is set to output everything from Right to Left... any idea why the Category Lines are still LTR?
Alternatively, if the page is using tables for layout, look for align="left" in the generated HTML
Mark,
You are a genius!!! It was the CSS that was overriding my RTL settings. I set the
text-align to "right" and that fixed it.
Thanks a million and happy new year
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Convert to Right-to-Left
Glad to be of helpmaximoox wrote:You are a genius!!! It was the CSS that was overriding my RTL settings. I set the
text-align to "right" and that fixed it.
Thanks a million and happy new year
Been there myself when there was nobody around to help.... and spent days looking straight at the problem, but only seeing what I expected to see, so I missed it completely.
It can be a real pain working on a multilingual site, even when it's a standard western (ISO-8859-1) language. Non-Roman characters cause enough problems to those unfamiliar with languages, and rtl can cause even more problems.