Landing Page Details

Description

Translate is an easy but flexible PHP class to help you to create multilangual websites. It consist only of one class.php file and as many language files as you want. The simple structure makes it easy to add additional languages. Translate can automatically detect the browser language, supports placeholder in your predefined texts and allowes to define a fallback language. Give it a try and you will see how easy it is to create multilanguage websites.

Installation

The integration or better the necessary preparation of “Translate” to use multiple languages is very simple. Only 3 lines of code are enough: require_once (‘Translate/Translate_class.php’); $translate = new translate(); $translate->setBrowserLanguage();

Features

  • Ready to use with 3 lines of code
  • easy to extend with new languages (just copy an existing language file)
  • simple structure (translate_class.php and the language files.)
  • no errors because of a defined fallback language
  • detects the browser language of the user automatically or via the IP address
  • text parts can contain placeholders for variables

Please help me

If you are going to rate the script less than 5 stars, please tell me what I can do to make it 5 stars for you and I will fix it. I would love to hear your suggestions on how I could improve the script, leave me a comment or send me an email and your suggestion might make it in to a future version!
  • oemmeo

    2013-06-21 00:12:27
    Purchased Reply

    Hi, great script, just what I was looking for! I'm using it to translate my personal page, but I came across a little problem. I'm using a one page solution with different sections that are displayed using jquery.easytabs. Now when I click on a flag to translate to a different language it will always take me back to the first tab. Is there a way for your script to remember what tab the user was on before and take him to the same tab in the other language? Tina

  • christophdb

    2013-06-21 06:17:33
    Purchased Reply

    Hey Tina, I just checked. Easytabs uses ankors like #tab1 or #tab2 for the selection of the correct tab, right? Then you have to add the anchor to the link that is used by the flags. You can get the anchor with parseurl (see fragments: http://ca.php.net/manual/en/function.parse-url.php) Best regards Christoph

  • oemmeo

    2013-06-22 19:28:12
    Purchased Reply

    Hi Christoph, thanks for the hint. I tried that (must admit I am not a programmer, basic things are ok though) but it seems that easytabs is not adding the current tab to the URL (the URL always stays the same), I'll try to get the active tab via javascript to add it to the flag links. I hope that's going to work somehow. Tina

  • oemmeo

    2013-06-22 22:16:33
    Purchased Reply

    Ok, this seems to be really tricky. I cannot use parse_url because it is not getting the # since it's created by the javascript on the client and not on the server (fragment for parse url is empty therefore). I've been trying to incorporate a javascript in the php part where the url for the language is created: getAllLanguages(); for($i = 0; $i < count($langArray); $i++){ echo "

    "; echo "if(window.location.hash) {var hash_value = window.location.hash.replace('#','');document.write(hash_value);};"; echo ""; echo "?lang=". $langArray[$i] ."'>
    "; }?> but that does not result in the correct ouptut for some reason. It's somehow breaking the url.... Unfortunately I don't know why. The javascript on its own is working....

  • oemmeo

    2013-06-22 22:17:39
    Purchased Reply

    ok, sure I know why, won't parse a script within an a tag. how else could I do this?

  • oemmeo

    2013-06-22 23:10:07
    Purchased Reply

    hm, strange, why is it working this way: getAllLanguages(); for($i = 0; $i < count($langArray); $i++){ echo "

    "; echo ""; echo "
    "; }?> with the url output looking like this /?lang=de#about?lang=de but not this way with the correct url output (I can see that the correct language thing is attached to the url but the language of the content isn't switched. url looks like this which seems to be correct, right? /#about?lang=de: getAllLanguages(); for($i = 0; $i < count($langArray); $i++){ echo "
    "; echo ""; echo "
    "; }?>

  • oemmeo

    2013-06-22 23:15:08
    Purchased Reply

    umpf, bugger.... the script is only getting the hashtagthing when I refresh the page...

  • christophdb

    2013-08-07 17:21:07
    Purchased Reply

    hey Tina, sorry for no responses within the last weeks. My second son was born and I didn't checked the comments on codecanyon. Can you send me via codecanyon a mail with the link to your page. I want to have a deeper look and I will try to solve your problem.

  • pocakka

    2016-12-31 05:45:26
    Purchased Reply

    I just want to say "!!Thank You!!" for this f_king awesome script. You saved me plenty of time. Well working, and very easy to use. Thumb Up!

  • christophdb

    2017-01-08 08:44:05
    Purchased Reply

    Hi pocakka, thank you very much. Best regards Christoph

  • Gisnet

    2017-03-05 04:41:53
    Purchased Reply

    Please i want to ask if my page is translated from Envglish to another page will my visitor be able to search the list of items in my database? with their set language. Thanks

  • christophdb

    2017-04-20 05:35:31
    Purchased Reply

    Hi Gisnet, The module does not translate for you. You have to provide the language file - then your user can search the list of items. Best regards Christoph

  • stub

    2013-04-10 11:11:58
    Purchased Reply

    Like kazooki asked. Are all the flags included or where do we get them from?

  • christophdb

    2013-04-16 22:34:36
    Purchased Reply

    Hey stub, go to the webpage: http://www.famfamfam.com/lab/icons/flags/. There you will find 247 flags (free for any use and purpose). Best regards, Christoph

  • dockydoc

    2013-01-28 03:52:59
    Purchased Reply

    Hello, Is it possible to combine jquery mobile and your class ? Thanks Olivier

  • christophdb

    2013-01-28 17:14:28
    Purchased Reply

    Hey dockydoc, to be honest I have no experience with jquery mobile. I don't know what I can offer to you: it is possible to take back a purchase if it is not working?

  • rajlata

    2014-11-20 21:34:12
    Purchased Reply

    Is this converter can be use for English to Arabic language.

  • christophdb

    2014-12-05 00:56:30
    Purchased Reply

    yeah the converter can be used for english and arabic. But please be aware that the converter does not translate for you. You as owner of the website have to provide the language translations. I offer you an easy way to include your language text files to the page !

  • mojeer

    2015-07-06 07:18:13
    Purchased Reply

    Hi, How to do this: $page_name = $translate->_('homepage'); it return this error Fatal error: Call to a member function _() on a non-object

  • christophdb

    2015-11-20 00:51:48
    Purchased Reply

    Hi mojeer, Hi xsxoxs, sorry for the late response. I founded my own business 3 month ago and got my third kid – so trouble and sleepless nights are a constant situation. that is the wrong way. $translage->_('homepage') does not deliver a variable. It prints or echos the text snippet that belongs to 'homepage' in your language files. Best regards Christoph

  • xsxoxs

    2015-09-27 16:29:50
    Purchased Reply

    Hi I have more than 3 PHP website and i want to buy automatic translator for my websites i have some question 1- is your script using google translate ? (i prefer google translate) 2- is this full source code ? i want use on all 3 websites, or buy license for each site 3- is there any limitation on translate or not ? 4-is it need to change my codes on site or no? answering this questions help me to choose best for my websites thanks

  • christophdb

    2015-11-20 00:49:56
    Purchased Reply

    Hi xsxoxs, sorry for the late response. I founded my own business 3 month ago and got my third kid - so trouble and sleepless nights are a constant situation. Now to your question: 1) no I am not using google translate. You have to provide language files that are used to replace variables on your website. 2) you receive the complete source code and you can use it on any website 3) no limitations but you have to provide the language files 4) yes you have to replace the current text with variables. Best regards Christoph

  • costainternet

    2012-11-10 09:47:50
    Purchased Reply

    Hi, Thanks for the explanation. Yes, I am confused. If i buy this and send you my php file, can you help me?. I just need to have the option to translate it to english with the icon flag thanks

  • costainternet

    2012-11-11 01:51:13
    Purchased Reply

    Christoph, Can I do the fix text part by your script and the dynamic part by Google translator on the fly?. Thanks

  • christophdb

    2012-11-13 01:28:36
    Purchased Reply

    Hey costainternet, yes, my php class can translate the fix text part and google could translate the text on the fly. BUT I just checked: google wants to have 20 $ per 1 Million characters of text: https://developers.google.com/translate/v2/pricing?hl=de and you have to include the google translate api. Best regards, Christoph

  • GaryPickles

    2014-10-13 02:53:06
    Purchased Reply

    Hi, Got the PHP script working on all pages of my website, have set up language files for both English and German, it works fine when i click on the flags to change, but it defaults to english when i change pages on the site, was hoping that once you selected German it would stay on german. I'm using your code snippet for the session variable, but not been very good at PHP don't know if I'm doing anything wrong. I'm using your code directly from the sample file in the download. Thanks, Gary setBrowserLanguage(); if(isset($_GET['lang'])){ $translate->setLanguage(substr($_GET['lang'], 0, 2)); $_SESSION['lang'] = substr($_GET['lang'], 0, 2); } if(isset($_SESSION['lang'])){ $translate->setLanguage($_SESSION['lang']); } ?>

  • christophdb

    2014-10-14 04:57:54
    Purchased Reply

    Hi Gary, is it possible that you forgot the "session_start();" at the beginning of the file? In this case the session values are not saved... If that is not the case, can you send me the complete code? Best regards Christoph

  • GaryPickles

    2014-10-14 07:13:24
    Purchased Reply

    Hi, That worked thank you, think I'm doing it right, I just added "session_start();" into the beginning of the above code which is in the head of each of the 10 pages that need to have translation on them, Is this right? I'm not starting 10 sessions am i ? Just checking when it say required once, It dose need to be on each page? Thanks Gary

  • christophdb

    2014-10-14 07:37:45
    Purchased Reply

    Hi Gary, you add session_start() one time at every page. That is correct.

  • GaryPickles

    2014-10-14 08:52:57
    Purchased Reply

    Thank you, all working just how just how i need it, must say easy to set up and get up and running, just need this final touch. Thanks Gary

  • christophdb

    2014-10-14 18:17:41
    Purchased Reply

    :-)

  • ChrisTERiS

    2015-11-22 18:30:32
    Purchased Reply

    Hello,

    Do you know how I can echo the variables in Smarty PHP templates? I know that Smarty supports {php}{/php} tags but I want to avoid using them. Currently I'm adding all phrases in an array and then I'm dispaying them in the templates like: {$LANG.my_phrase}

    Thank you
    Christos

  • christophdb

    2015-11-30 06:02:13
    Purchased Reply

    Hi Chris, I have now experience with smarty php templates. Why do you want to avoid php code in the templates? Best regards Christoph

  • vincenzolopalo

    2012-11-14 05:22:45
    Purchased Reply

    one question: is it possible add cookie feature? I mean, if an user select spanish language, browser saves this preference in cookies. Make sense this feature?

  • christophdb

    2012-11-14 08:26:18
    Purchased Reply

    Hello Vincenzolopalo, the php class allows to store the selected value in a php session (which is basically a cookie). But probably I didn't got the point. Can you explain why a cookie is better than a session? Best regards, Christoph

  • mossman0

    2013-10-13 08:03:03
    Purchased Reply

    Hi Script author, I bought the script, but I can not configure it. I the help folder contents and code comments are not very helpful. Can you explain step by step what I have to do. Thanks for all.

  • christophdb

    2013-10-15 00:04:03
    Purchased Reply

    Hi mossman0, upload everything from the source folder to your webspace. The index.php is a good example to start with. 1) You need to include the 3 lines of code to include the translate class. 2) define any text snippets in the language files. (de_lang.php or en_lang.php in the subfolder Translate). e.g. to en_lang.php: 'first_text' = 'my first sentence'; e.g. to de_lang.php: 'first_text' = 'mein erster Satz.'; 3) with "$translate->_('first_text');" php will write to the webpage the text defined for the current language. If that does not work. Send me your files and I will help you for a concrete example. Best regards Christoph

  • costainternet

    2012-11-10 09:54:50
    Purchased Reply

    By the way some text parts of the page I sent you is fix text, and some text is variable text, variable I mean it comes from a CMS that the user enters. I dont know how this variable text can be translated with your script

  • christophdb

    2012-11-10 11:20:18
    Purchased Reply

    Hi costainternet, I will answer your last two questions: 1) I already wrote all necessary lines of code to include the english flag in your page and to switch between the languages. Just follow my explanation and it will work. If you have questions I will help you but I am sorry I will not do the coding for you. 2) sorry but my php class can not do miracles. If you don't have the translated text then the translate php class can not help you. The only idea I have in such a situation is a on the fly usage of google translator api. I never did this but I think it should be possible. If you have the text (fix or from a cms) in all languages available then it is no problem to show your page with my php class into the different languages. Even variables in the texts are no problem. Best regards, Christoph

  • alexdeluxe

    2012-11-13 05:39:04
    Purchased Reply

    Hallo Christoph, i am very interested in your script, but i do not understand how it will work. Can you please explain a bit more? How does the system know the connection to the translation? using mo/po? Let's say i have page-de.html with german headlines and paragraphs. Now i need this page in spanish page-es.html for example. What code do i put at the positions where the original (german) text was? Danke, Alex

  • christophdb

    2012-11-13 08:00:48
    Purchased Reply

    Hey Alex, in your case the usage of the translation class is very simple. First you define two files: lang_de.php and lang_es.php. In the lang_de.php you define all text parts as variables like: $this->TXT['headline1'] = 'Dies ist eine Überschrift'; $this->TXT['text1'] = 'Dies ist der erste Absatz'; In the lang_es.php you define with the same variables the spanish text parts: $this->TXT['headline1'] = 'Este es un titular'; $this->TXT['text1'] = 'Este es el primer párrafo'; Then you change you don't have two html files but instead you use one php file (lets call it index.php). In this file you load my php class and replace the former text parts with the following: echo $translate->_('headline1') and $translate->_('text1'). That is all. Know you hopefully understand that in your index.php you call for a variable and the php class makes sure that the correct language is used. I hope this explanation helps you. Christoph

  • LUCK71490

    2016-02-19 06:23:00
    Purchased Reply

    por favor faça o reembolso pois o codigo não serviu pois nao tem o idioma portugues

  • mySudi

    2012-11-11 00:42:56
    Purchased Reply

    Amazing script! Good luck with sales mate! greetings CodeTensae

  • christophdb

    2012-11-13 01:27:08
    Purchased Reply

    thanks CodeTensae

  • zadesign

    2013-04-08 02:03:29
    Purchased Reply

    One Question christophdb: How can i run your script as Ajax? Maybe with jQuery? Your script loads the page again and again and i think it's not very well. Thank You

  • christophdb

    2013-04-16 22:33:53
    Purchased Reply

    Hey zadesign, you are right. The translate PHP class loads the page again if you switch the language. Personaly I think this is no problem because the user should change the language only one time (and then stay with the correct language) but for sure there might be the requirement to change it directly. I will think about it.

  • zadesign

    2013-07-09 17:59:42
    Purchased Reply

    Christophdb Hi, When will this implemented? That would be great. An Ajax version would be very useful for languages. Thnak You!

  • christophdb

    2013-08-07 17:18:18
    Purchased Reply

    Hey zadesign, due to the birth of my second son I have absolutely no time for this enhancement. I am sorry.

  • SamWorld

    2016-01-31 22:18:59
    Purchased Reply

    hello, how can i contact you ,before i buy this one? thanks