Jump to content
Larry Ullman's Book Forums

Multilangual Cms


Recommended Posts

Larry please tell me if you have any book where you explain how you can make a website to be multilingual.

I created a database, that I think that will work with what I want, but I'm not sure how to do the code :).

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 don't know how to make that switch that show flags images and change every time the content, when you change the flags.

Link to comment
Share on other sites

In my PHP & MySQL for Dynamic Web Sites book, I have an example of a multilingual forum. Although, to be clear, the interface elements are multilingual, not the content, but that'd be an easy change to make. The short answer is you store a language identifier in a session or cookie (after the user clicks on a flag) and then use that identifier to know what language to display. 

Link to comment
Share on other sites

 Share

×
×
  • Create New...