Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Location
    in .........
    Posts
    263
    Thanks
    183
    Thanked 0 Times in 0 Posts

    How to translate a php variables to English

    Hi, I need to know a way to translate my php variables to or from English and any other languages, so I could translate the variable use entered to the language I want.
    hope if any one could help

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    The variable or the value? The variable itself is irrelevant really. The value is a simple search and replace.
    If you want it to be swappable, you will need to either write or download something for language management. These can be as simple as constants used as replacements based on the language specified. The most difficult part is optimizing them to never retrieve more than they actually need to do, which is somewhat difficult since you need to capture and replace after the fact.

  • Users who have thanked Fou-Lu for this post:

    Mido™ (02-02-2012)

  • #3
    Regular Coder
    Join Date
    Aug 2009
    Location
    in .........
    Posts
    263
    Thanks
    183
    Thanked 0 Times in 0 Posts
    Yes I mean the value, the variable's value but sorry that I just wrote in variable.
    and I didn't understand all your other explain but what I want to do is to translate the name of the country from French "or another" to English, so the user will write it in French then I'll translate it to English before inserting to the database.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I'm going to say, no on this, at least, not easily.
    Sounds like you want to take a phrase input in one language and translate it into another right then and there. This requires a lot more than a simple replacement engine; you need to contact an actual lexical analyst to determine how you convert the syntax of one language into another. Its not just about word replacement at this point, its about grammatical as well.

    If its a small set of hard coded words, then yes this is as easy as a simple str_replace. But I'm not sure if you are looking for dynamic conversion which would require a tremendous amount of work, or just something simple.

  • Users who have thanked Fou-Lu for this post:

    Mido™ (02-04-2012)

  • #5
    Regular Coder
    Join Date
    Aug 2009
    Location
    in .........
    Posts
    263
    Thanks
    183
    Thanked 0 Times in 0 Posts
    No it isn't a small set of hard coded words and str_replace won't do it, are you could tell me what's the solution and that dynamic conversion who could do it?

  • #6
    Regular Coder
    Join Date
    Jan 2012
    Posts
    271
    Thanks
    2
    Thanked 65 Times in 65 Posts
    google translate has an API... that would be your best choice IMHO

    http://code.google.com/apis/language.../overview.html

  • Users who have thanked jmj001 for this post:

    Mido™ (02-11-2012)

  • #7
    Regular Coder
    Join Date
    Aug 2009
    Location
    in .........
    Posts
    263
    Thanks
    183
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jmj001 View Post
    google translate has an API... that would be your best choice IMHO

    http://code.google.com/apis/language.../overview.html
    can you please explain some in how to use it?

  • #8
    Regular Coder
    Join Date
    Jan 2012
    Posts
    134
    Thanks
    0
    Thanked 32 Times in 32 Posts
    #1, the API now costs money:

    Important: Google Translate API v2 is now available as a paid service only, and the number of requests your application can make per day is limited.
    #2, if you want to use it, you'll have to read up on the documentation. It's very thorough and nobody nobody can just tell you how to use it.


  •  

    Posting Permissions

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