Multilanguage CMS

I created a database, that I think that will work with what I want, but I’m not sure how to do the code, html header and php, to make the cms multilingual

CREATE TABLE languages (
lang_id tinyint(4) unsigned NOT NULL AUTO_INCREMENT,
lang_code varchar(10) NOT NULL,
language varchar(50) NOT NULL,
PRIMARY KEY (lang_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

INSERT INTO languages VALUES(1, ‘ro’, ‘Romana’);
INSERT INTO languages VALUES(2, ‘en’, ‘English’);

CREATE TABLE pages (
page_id int(11) unsigned NOT NULL AUTO_INCREMENT,
title varchar(255) NOT NULL,
identity varchar(150) NOT NULL,
PRIMARY KEY (page_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;

INSERT INTO pages VALUES(1, ‘Home’, ‘index’);
INSERT INTO pages VALUES(2, ‘About us’, ‘about’);
INSERT INTO pages VALUES(3, ‘Services’, ‘services’);
INSERT INTO pages VALUES(4, ‘Testimonials’, ‘testimonials’);
INSERT INTO pages VALUES(5, ‘Contact us’, ‘contact’);
INSERT INTO pages VALUES(6, ‘Page not found!’, ‘error’);

CREATE TABLE pages_content (
page int(11) unsigned NOT NULL,
language tinyint(4) unsigned NOT NULL,
name varchar(150) NOT NULL,
content text,
meta_title varchar(255) NOT NULL,
meta_description varchar(255) NOT NULL,
meta_keywords varchar(255) NOT NULL,
PRIMARY KEY (page,language),
KEY language (language)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE users (
user_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
type ENUM(‘member’,‘admin’) NOT NULL,
username VARCHAR(30) NOT NULL,
email VARCHAR(80) NOT NULL,
pass VARBINARY(32) NOT NULL,
first_name VARCHAR(20) NOT NULL,
last_name VARCHAR(40) NOT NULL,
date_expires DATE NOT NULL,
date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
date_modified TIMESTAMP NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
PRIMARY KEY (user_id),
UNIQUE KEY username (username),
UNIQUE KEY email (email)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

I have the en and ro flags in a folder and I need a little help to put the flags in header and bring the content when the flags are changing. I am not advanced in php that’s why I need a little help.

You’re going to have to try and learn and do more on your own. This forum isn’t an “ask for code” forum. It is a “Ask for help about PHP, when you’ve tried to code” forum.

Scott

IMHO you should look into using

WordPress supports it and AFAIK it could be used most any site.

Cons: you rely upon translators
Pros: they are more likely to provide better translations than are currently possible by automated ways

Thank you Mittineague, I will try it.

Larry Ullman helped me with my question. He recommended me his book, PHP & MySQL for Dynamic Web Sites, and in chapter 17 he explains very simple how to do make the language switcher in cms.

A book is a good start to learn. :smile:

gettext is interesting. Thanks for that Mitt. I also found that PHP supports it directly with an extension.

http://php.net/manual/en/book.gettext.php

This is a pretty cool set of articles on using it here at Sitepoint.

Scott

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.