multilanguage website

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mariano López

    multilanguage website

    I'm trying to make a multilanguage website. When the user enters the site, I want to detect the language and automatically make a redirection. How can I do this? And how should I organize my data base so the user can switch languages easily?

    Thanks.
  • Agelmar

    #2
    Re: multilanguage website

    Mariano López wrote:[color=blue]
    > I'm trying to make a multilanguage website. When the user enters the
    > site, I want to detect the language and automatically make a
    > redirection. How can I do this? And how should I organize my data
    > base so the user can switch languages easily?
    >
    > Thanks.[/color]

    Detecting language... not easy at all. You could try to do a reverse lookup
    on the IP address and grab a country from that, but that may be slow.
    Personally, I would display either a map of the world with regions
    clickable, or (my personal preference) flags. Then just keep that in the
    query string (e.g. blah.php?lang=e n) or in a session variable (perhaps less
    preferable if you have a ton of users). When querying your db for content,
    just tack on an extra row (of type enum) for the language.

    My $.02
    // Ian Fette
    // Proponent comp.lang.php


    Comment

    • Mariano López

      #3
      Re: multilanguage website

      Agelmar wrote:[color=blue]
      > Mariano López wrote:[color=green]
      >> I'm trying to make a multilanguage website. When the user enters the
      >> site, I want to detect the language and automatically make a
      >> redirection. How can I do this? And how should I organize my data
      >> base so the user can switch languages easily?
      >>
      >> Thanks.[/color]
      >
      > Detecting language... not easy at all. You could try to do a reverse
      > lookup on the IP address and grab a country from that, but that may
      > be slow. Personally, I would display either a map of the world with
      > regions clickable, or (my personal preference) flags. Then just keep
      > that in the query string (e.g. blah.php?lang=e n) or in a session
      > variable (perhaps less preferable if you have a ton of users). When
      > querying your db for content, just tack on an extra row (of type
      > enum) for the language.
      >
      > My $.02
      > // Ian Fette
      > // Proponent comp.lang.php[/color]

      Hi. I've found an easy solution to language detection by using Javascript (it checks the browser's language configuration).

      Now I'm thinking if I'm going to use a session variable (I didn't want to mess with it, but maybe I do ;-)))

      Thanks.

      Comment

      • sam

        #4
        Re: multilanguage website

        You can use the ip-to-country database.

        ---------------- CUT HER ------------------------------
        $user_ip = $_SERVER['REMOTE_ADDR'];
        $country_code_t ype = "name"; // can be "name", "code2" or "code3"

        $h =
        fopen("http://ip-to-country.directi .com/country/$country_code_t ype/$user_ip"
        ,'r');
        $user_country = fgets($h,4096);
        fclose($h);
        ---------------- END -----------------------------------

        You can download the database from http://ip-to-country.directi.com and
        you access it locally if you want.

        For more details: http://ip-to-country.directi.com

        Hope this helps.


        "Mariano López" <vidriosjujuy-NOSPAM-@infovia.com.ar > wrote in message
        news:bepmdb$7qd mv$1@ID-156496.news.uni-berlin.de...
        I'm trying to make a multilanguage website. When the user enters the site, I
        want to detect the language and automatically make a redirection. How can I
        do this? And how should I organize my data base so the user can switch
        languages easily?

        Thanks.


        Comment

        • Louis-Philippe Huberdeau

          #5
          Re: multilanguage website

          You might want to look over some HTTP request headers:

          $_SERVER[ 'HTTP_ACCEPT_LA NGUAGE' ]

          Or look over get_browser(), there is one of the values that identifies
          the browser's language if I remember well, but it should be the same value.

          Agelmar wrote:[color=blue]
          > Mariano López wrote:
          >[color=green]
          >>I'm trying to make a multilanguage website. When the user enters the
          >>site, I want to detect the language and automatically make a
          >>redirection . How can I do this? And how should I organize my data
          >>base so the user can switch languages easily?
          >>
          >>Thanks.[/color]
          >
          >
          > Detecting language... not easy at all. You could try to do a reverse lookup
          > on the IP address and grab a country from that, but that may be slow.
          > Personally, I would display either a map of the world with regions
          > clickable, or (my personal preference) flags. Then just keep that in the
          > query string (e.g. blah.php?lang=e n) or in a session variable (perhaps less
          > preferable if you have a ton of users). When querying your db for content,
          > just tack on an extra row (of type enum) for the language.
          >
          > My $.02
          > // Ian Fette
          > // Proponent comp.lang.php
          >
          >[/color]

          Comment

          • Zurab Davitiani

            #6
            Re: multilanguage website

            Mariano López wrote on Saturday 12 July 2003 12:10:
            [color=blue]
            > I'm trying to make a multilanguage website. When the user enters the site,
            > I want to detect the language and automatically make a redirection. How
            > can I do this? And how should I organize my data base so the user can
            > switch languages easily?[/color]

            If you run Apache or any capable web server, then you can leave the client
            language detection and preference to it and let it serve appropriate
            file(s). See more in Apache docs.

            Then, based on which file is served, set language preferences in your PHP
            app and allow change back and forth. As far as separating data, make sure
            all language-specific content is defined separately from your main
            application, and include() language-specific include files (containing
            appropriate variables and language-specific content) in each script that
            outputs or otherwise processes said content.

            Depending on complexity of your application, and variety of languages this
            could be anywhere from very simple to somewhat challenging.

            --
            Business Web Solutions
            ActiveLink, LLC

            Comment

            Working...