SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best way to handle multiple languages in a script?

    I am building a script that will have multiple language files. What is the best way to "use" these language files within the script?

    Which method is better and why?

    1. Selected language file is loaded once at login. All values of the file (about 300 variables) are loaded as session values so they're available to script/file in the application.

    2. Selected lanague file name is saved as a session value. For each file/script in the application, this value is used to read the appropriate language file.

    So I guess my question is.. what is better? To load all the values once at the beginning, or to load them every time they are needed?

    Thanks for any help!

  2. #2
    SitePoint Addict Clete2's Avatar
    Join Date
    Mar 2002
    Location
    Columbia, South Carolina
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    load as needed, it would slow your script down to load every single language at the beginning and is not nessicary(sp?). Just add a ?lang=en or something to load English.
    My Blog
    My Photography Website
    Linux user #339185

  3. #3
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Probably all at the start for speed. If you want to see how this sort of thing is used, phpBB uses different languages with a huge array $lang[]. It's probably good to have a look at if this is the first time you're going to do something like this.

  4. #4
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    load as needed, it would slow your script down to load every single language at the beginning
    He wouldn't be loading all at once. Only the selected language -
    Selected language file is loaded once at login

  5. #5
    SitePoint Addict Clete2's Avatar
    Join Date
    Mar 2002
    Location
    Columbia, South Carolina
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by DJ P@CkMaN
    Probably all at the start for speed. If you want to see how this sort of thing is used, phpBB uses different languages with a huge array $lang[]. It's probably good to have a look at if this is the first time you're going to do something like this.
    Wouldn't it slow it down to load all the language files at once rather than one or two later on?

    *Is a little sleepy*
    My Blog
    My Photography Website
    Linux user #339185

  6. #6
    SitePoint Addict Clete2's Avatar
    Join Date
    Mar 2002
    Location
    Columbia, South Carolina
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by DJ P@CkMaN

    He wouldn't be loading all at once. Only the selected language -
    Oh. Then I must be tired, I thought he was loading them all at once and using only one of them.
    My Blog
    My Photography Website
    Linux user #339185

  7. #7
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by DJ P@CkMaN
    Probably all at the start for speed. If you want to see how this sort of thing is used, phpBB uses different languages with a huge array $lang[]. It's probably good to have a look at if this is the first time you're going to do something like this.
    Are the $lang variables generated over again for each page, or is it dumped into a session variable at the start?

    In other words, is there a call to the appropriate language file for each page that is loaded?

  8. #8
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Generated in common.inc which is included in every page. The language doesn't use sessions.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •