-5

I want to translate text in my website like google translate (Not with it). I just need a sample php code that translate some of defined words (not the whole language). here is my example code:

    $text = "hello john";
    $translated_text = str_replace("hello", 'Hallo', $text);
    echo $translated_text;
    
does it execute fast on the server? do i have to translate word by word?
mh. bitarafan
  • 886
  • 9
  • 16
  • SO is not for people to do your research or coding for you, we are happy to debug any issues you have with existing code, but you need to show some effort on your end first. – Wobbles May 16 '16 at 20:22
  • i'm sorry, i dont want a complete code. i just want to know which functions in php is useful for that. – mh. bitarafan May 16 '16 at 20:26
  • "SO is not for people **to do your research** or coding for you" – Wobbles May 16 '16 at 20:27
  • so where can i find coding answers. – mh. bitarafan May 16 '16 at 20:29
  • You didn't ask a coding question. If you have a question regarding your code, then post the code and reword your question. – Wobbles May 16 '16 at 20:31
  • @Wobbles : It's OK...Give him a little bit hint as he is asking nicely brother...! – Umair Shah May 16 '16 at 20:32
  • simple google first. php has no ONE function for your request. its a project not issue. :) – Hossein May 16 '16 at 20:33
  • Well..! you need an api to do it as because it can't be done with just a piece of PHP code brother..! – Umair Shah May 16 '16 at 20:33
  • @UmairShahYousafzai Has nothing to do with niceties, this site is for resolving coding issues, which this is not and the reason why flags exist precisely for questions like this. – Wobbles May 16 '16 at 20:34
  • @Wobbles : Yes..Exactly but I can see that the OP is trying to learn something but his method is wrong so a little bit hint can't hurt..Indeed he or she is not following the rules..! – Umair Shah May 16 '16 at 20:37
  • http://stackoverflow.com/help/on-topic – Wobbles May 16 '16 at 20:38
  • i need a small translator that translate some of defined words not for the whole language. – mh. bitarafan May 16 '16 at 20:38
  • @mh.bitarafan You still have not shown any effort to do your own research or start writing your own code. – Wobbles May 16 '16 at 20:48
  • @mh.bitarafan Read [How To Ask](http://stackoverflow.com/help/how-to-ask) for help on what questions are ment for SO and how you should go about asking them. – Wobbles May 16 '16 at 20:49

1 Answers1

0

You need to fill a dictionary in order to lookup for the words you want to translate.

Take a look at this answer, the code is meant to filter bad words, but should work in your case.

Community
  • 1
  • 1
mattimatti
  • 967
  • 8
  • 15