Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. detect client language

detect client language

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
questioncom
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    I want to know how can I detect the client language so if it's arabic then leave it as www.mydomain.com but if it's english then redirect to www.mydomain.com/en?

    G A 2 Replies Last reply
    0
    • J Jassim Rahma

      I want to know how can I detect the client language so if it's arabic then leave it as www.mydomain.com but if it's english then redirect to www.mydomain.com/en?

      G Offline
      G Offline
      Graham Breach
      wrote on last edited by
      #2

      If the user's browser is set up properly, you can use $_SERVER['HTTP_ACCEPT_LANGUAGE'] to find out which languages they prefer to use.

      J J 2 Replies Last reply
      0
      • G Graham Breach

        If the user's browser is set up properly, you can use $_SERVER['HTTP_ACCEPT_LANGUAGE'] to find out which languages they prefer to use.

        J Offline
        J Offline
        Jassim Rahma
        wrote on last edited by
        #3

        does PHP has global file similar to the global or config files in ASP.NET or I should add the language check in every php file in my website?

        G 1 Reply Last reply
        0
        • G Graham Breach

          If the user's browser is set up properly, you can use $_SERVER['HTTP_ACCEPT_LANGUAGE'] to find out which languages they prefer to use.

          J Offline
          J Offline
          jan lucas
          wrote on last edited by
          #4

          when I check $_SERVER['HTTP_ACCEPT_LANGUAGE'] on Chrome it gives: "en-GB,en;q=0.8" any idea what "q=0.8" means?

          My logic is impeccable; my arithmetic lets me down.

          L 1 Reply Last reply
          0
          • J jan lucas

            when I check $_SERVER['HTTP_ACCEPT_LANGUAGE'] on Chrome it gives: "en-GB,en;q=0.8" any idea what "q=0.8" means?

            My logic is impeccable; my arithmetic lets me down.

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            It means Microsoft estimates your command of the English language is 80%, which is pretty good actually. More here[^] :)

            Luc Pattyn [My Articles] Nil Volentibus Arduum

            J 1 Reply Last reply
            0
            • L Luc Pattyn

              It means Microsoft estimates your command of the English language is 80%, which is pretty good actually. More here[^] :)

              Luc Pattyn [My Articles] Nil Volentibus Arduum

              J Offline
              J Offline
              jan lucas
              wrote on last edited by
              #6

              Luc Pattyn wrote:

              It means Microsoft estimates your command of the English language is 80%

              Microsoft? Surely it must be Google Chrome who made the estimate? ...and how does it (dare it!) make that estimate?!?

              My logic is impeccable; my arithmetic lets me down.

              L 1 Reply Last reply
              0
              • J jan lucas

                Luc Pattyn wrote:

                It means Microsoft estimates your command of the English language is 80%

                Microsoft? Surely it must be Google Chrome who made the estimate? ...and how does it (dare it!) make that estimate?!?

                My logic is impeccable; my arithmetic lets me down.

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                You never have tried Google Translate, have you? Google knows zilch about languages. :-D

                Luc Pattyn [My Articles] Nil Volentibus Arduum

                1 Reply Last reply
                0
                • J Jassim Rahma

                  does PHP has global file similar to the global or config files in ASP.NET or I should add the language check in every php file in my website?

                  G Offline
                  G Offline
                  Graham Breach
                  wrote on last edited by
                  #8

                  No, you would normally put anything you need to use on multiple pages into an include file, then load it on every page using include, require, include_once or require_once. ... unless you are using a framework, then there should be somewhere already that you can put code to execute on each request - but that will depend on the framework. Or you could possibly skip checking it in PHP at all, and use a .htaccess file to redirect to a different path depending on the Accept-Language header.

                  1 Reply Last reply
                  0
                  • J Jassim Rahma

                    I want to know how can I detect the client language so if it's arabic then leave it as www.mydomain.com but if it's english then redirect to www.mydomain.com/en?

                    A Offline
                    A Offline
                    Avinashwli
                    wrote on last edited by
                    #9

                    You can redirect using user's timezone also..

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups