Jump to content

Multiple languages


moon 111

Recommended Posts

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 ;;)

Link to comment
Share on other sites

  • 2 weeks later...

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.