Hello

I followed this link from google to http://www.phpbuilder.com/columns/white-eisenhamer20060915.php3
and could not seem to find a thread for it so i thought i would start one..

when i follwed the instructions on that page i got a error on language.php
line 41 so i added a end symbol on line 36..

from this-->require_once "{$lang}.php"
to this--->require_once "{$lang}.php";

but now when i look at the page on the net it says this:
Fatal error: Call to undefined function: http_build_query() in /home/nstream8/public_html/langauges/language.php on line 59

can anybody please help?
I just want to be able to change language so if there is a better link for this please post.

thanks for your help

    Try:
    require_once($lang . ".php");

    Also, did you misspell your languages path below:
    home/nstream8/public_html/langauges/language.php

      hello

      thx for the help...

      I did the change as you said to: require_once($lang . ".php");

      i noticed i had spelt the folder name language wrong so i changed that..
      the only place where i had to write the path was in index...
      require_once 'language.php';

      seems right to me
      Can you think of any other ideas??

      I read somewhere that this is not a good way to change language cause it doesent use cookies or something..

      Do you know off any links explaining other ways to do this??

        I would think that keeping a file full of variables associated with strings is going to be inefficient. The reason being that you will carry this file around the entire application and it will take up in-core memory if you have lots of them.

        Look at get_text() as a way to do language translation. Although I have no experience using it, I do plan ahead with my applications just in case by wrapping strings with _("translate this") before I echo out.

        Before you can use gettext though, you have to build it into PHP. I just so happened to write an article on how to build gettext into PHP on my website earlier this month. It doesn't describe how to use gettext but rather how to build it into PHP.

        For more information you can go read about gettext here

          kkobashi wrote:

          I would think that keeping a file full of variables associated with strings is going to be inefficient.

          Not if you split it up according to the language. For example, you could create a directory 'lang' and it in have lang.en.php and lang.fr.php for the English and French languages, respectively. Inside those files would be the variables containing strings only for that language, and you'd simply include lang.(language chosen).php in your app.

          I'm pretty sure this is how applications such as phpMyAdmin support multiple languages.

            bradgrafelman wrote:

            Not if you split it up according to the language. For example, you could create a directory 'lang' and it in have lang.en.php and lang.fr.php for the English and French languages, respectively. Inside those files would be the variables containing strings only for that language, and you'd simply include lang.(language chosen).php in your app.

            I'm pretty sure this is how applications such as phpMyAdmin support multiple languages.

            Yes, that is how most do it. Its an easy, quick way. More so if you are the programmer, the translator, the Q/A guy. But for large multifile/multilanguage projects with teams, this is not a good way to manage it.

            Basically, one should use gettext facilities to get the job done. String variables/arrays/constants can take up a large chunk of PHP global space. Loading the strings, initializing, sucks up memory and CPU usage. String tables are best left on disk for lookup anyway because of their size. Loading in string tables for every PHP file with a string in it is wasteful. In addition, you want a policy/process to managing this. Too many cooks in the kitchen can set fires that add to the cost of development and create more headaches. Internationalization is a tedious, time consuming, and boring task.

            Rather than go into a long winded explanation, I wrote an article PHP localization on my thoughts. Although more complicated, I think the benefits outweigh the time spent using it.

              2 months later

              I'm sorry but i'm still a noob in php, i've tried to use the in http://www.phpbuilder.com/columns/white-eisenhamer20060915.php3 code but i have a problem when i try to input this:

              <?php
              // Include our language library:
              require_once 'language.php';
              ?>

              ... in my index.php file i have a problem, nothing happens, nothing appears... it doesn't appear nothing really not even a single line of the code in html that i have next...

              Can you guys help me?!

                Write a Reply...