moon 111 Posted September 29, 2008 Share Posted September 29, 2008 I'm building a website that has two languages: English, and Hebrew. Now, all the users need to have their information in both English and Hebrew. How should I do this? Have two databases, one for each language? I really don't know what to do. Any suggestions? Thanks, - Moshe Quote Link to comment Share on other sites More sharing options...
joliocesar Posted September 29, 2008 Share Posted September 29, 2008 hey , i solve this problem on my project by 2 table on my database ! one table persian and one table english any time i need persian language i call persian table fields and any time i need english language i call english table fields ... i dont know this method is standard but this is good enough for me ; Quote Link to comment Share on other sites More sharing options...
Acs Posted October 1, 2008 Share Posted October 1, 2008 I use defines, but I think there is a language extension for php that is suppose to accomplish this in an easier form. Quote Link to comment Share on other sites More sharing options...
keeB Posted October 10, 2008 Share Posted October 10, 2008 Localization is normally done with templates an external strings. Here's an example: main_en_Us.properties loginform.username.inputfield='Login' loginform.password.inputfield='Password' main.template.php <html> <form action="some.php" method="post"> <caption><?php load_localized_string('loginform.username.inputfield', $user->getLocale()); ?></caption> <input type="text" name="username" /> <caption><?php load_localized_string('loginform.password.inputfield', $user->getLocale()); ?></caption> <input type="password" name="password" /> </form> </html> wherever load_localized_string is stored: <?php function load_localized_string($resource, $locale) { $resource_file = null; if ($locale == "" || $locale == null) { $resource_file = "main_en_US.properties"; } // map $locale to $resource_file // load resource file // parse resource file // return value in resource file based on key } Very basic example of how I would implement this in PHP. I would probably load the entire file up front and have it cached for easier access. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.