phorcon3 Posted March 26, 2008 Share Posted March 26, 2008 could someone please tell me ...whats meant by this: Our current approach is to have a table of strings in various languages in a MySQL database as a central repository, which we load into APC cache on each server when we deploy code. Hitting MySQL on every page load for data that is as static as translations would not be great, so we don't do it. As for doing the string table lookups, we've wrapped all strings in our codebase in a translation function that basically uses the native-language (english) string and the current locale as an index into the APC cache's string array. how would u go about doing this? cause ive absolutely NO clue ...what im supposed to do with that. lol Link to comment https://forums.phpfreaks.com/topic/97940-multi-language/ Share on other sites More sharing options...
ansarka Posted March 26, 2008 Share Posted March 26, 2008 the requirement is simple different language string for each word will be stored in database when some user open the page for first time all the strings will be stored in a APC (Alternate php cache) , so when the user hits the each page , instead of querying the db for the string you can take it from cache , this will help you to increase the performance and reduce the use of bandwidth Link to comment https://forums.phpfreaks.com/topic/97940-multi-language/#findComment-501070 Share on other sites More sharing options...
phorcon3 Posted March 26, 2008 Author Share Posted March 26, 2008 and what do u think the database looks like? somethin like this? CREATE TABLE `langs` ( `page_id` tinytext NOT NULL, `en` text NOT NULL, `de` text NOT NULL, `es` text NOT NULL, `fr` text NOT NULL, ) TYPE=MyISAM AUTO_INCREMENT=1; +----------+--------------+---------------+---------------+---------------+ | index.php | English txt str | German txt str | Spanish txt str | French txt str | | view.php | English txt str | German txt str | Spanish txt str | French txt str | +----------+--------------+---------------+---------------+---------------+ but i dunno how to create the php file? <?php $page_id = $_SERVER['REQUEST_URI']; $lang_cookie = $_COOKIE['lang']; $a = mysql_query("SELECT * FROM `langs` WHERE `page_id` = '".$page_id."'"); $b = mysql_fetch_assoc($a); ?> and what if the html code looks like this: <?php echo '<div>waddup?</div>'; echo '<div>Here\'s some info u might be interested in</div>'; echo '<div><input type="submit" value="Submit" /></div>'; ?> how would i derive the diff. text strings? because u dont have just one string of text for each site ..its probably split up in diff. sections. oh man ..i just dont get it lol Link to comment https://forums.phpfreaks.com/topic/97940-multi-language/#findComment-501099 Share on other sites More sharing options...
phorcon3 Posted March 26, 2008 Author Share Posted March 26, 2008 oh, maybe it looks like this MySQL tables: CREATE TABLE `en` ( `page_id` tinytext NOT NULL, `str` text NOT NULL, ) TYPE=MyISAM AUTO_INCREMENT=1; CREATE TABLE `de` ( `page_id` tinytext NOT NULL, `str` text NOT NULL, ) TYPE=MyISAM AUTO_INCREMENT=1; Table: en +----------+----------------------------------------+ | index.php | waddup? | | index.php | Here's some info u might be interested in | | index.php | Submit | +----------+----------------------------------------+ Table: de +----------+----------------------------------------------------------------+ | index.php | was geht? | | index.php | Hier gibt's einige information die dich vielleicht interessieren würde | | index.php | Abschicken | +----------+----------------------------------------------------------------+ index.php <?php $page_id = $_SERVER['REQUEST_URI']; if(empty($_COOKIE['lang'])){$lang_cookie = 'en';}else{$lang_cookie = $_COOKIE['lang'];} $a = mysql_query("SELECT `str` FROM `".$lang_cookie."` WHERE `page_id` = '".$page_id."'"); while($b = mysql_fetch_assoc($a)) { $str .= $b['str'].','; } $strings = array($str); echo '<div>'.$strings[0].'</div>'; echo '<div>'.$strings[1].'</div>'; echo '<div><input type="submit" value="'.$strings[2].'" /></div>'; ?> ok, thats just really crappy codin ..i dont know if that would work ...or even be efficient.. Link to comment https://forums.phpfreaks.com/topic/97940-multi-language/#findComment-501113 Share on other sites More sharing options...
phorcon3 Posted March 26, 2008 Author Share Posted March 26, 2008 no ideas? : / Link to comment https://forums.phpfreaks.com/topic/97940-multi-language/#findComment-501240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.