Language values ​​from file or from the db (MULTILANGUAGE application)

Discussion in 'PHP' started by Argento, Jun 18, 2011.

  1. #1
    Hi, iam developing a multilanguage application, so i need array values loaded with language values.

    I think that i have two ways to do it:

    The first one, create an array on a file, and include it.

    for example:

    define('LANG','es');

    include('lang'.LANG.'.php');

    $lang['friend']= 'Amigo'; //Spanish value for friend

    Then i will replace the tags on the template for the lang values.

    Or i can save the values on the database -> id, varName, esVarValue (spanish value), enVarValue (english value)

    Then i use a loop and assign values ​​automatically

    while(.....)
    $name = varName db entry
    $lang[$name] = esVarValue db entry ...

    so ... which is better? maybe the first one is faster but maybe the difference in execution load is minimal ... second one seems more practical ...

    what should i do ??? thanks alot !
     
    Argento, Jun 18, 2011 IP
  2. trecords

    trecords Well-Known Member

    Messages:
    145
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #2
    I recommend to use .mo language files for php multilingual apps. these files are native Linux language files which not loads server too much.
    Ana it is also easy to add extra languages then.
     
    trecords, Jun 19, 2011 IP
  3. Argento

    Argento Active Member

    Messages:
    69
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    53
    #3
    Some example ???
     
    Argento, Jun 19, 2011 IP