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
https://forums.phpfreaks.com/topic/126256-multiple-languages/#findComment-652920
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
https://forums.phpfreaks.com/topic/126256-multiple-languages/#findComment-661549
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.