-2

In my website there are several english strings in the HTML and JS code ( NOT in the database ) and I need to translate these strings in others languages ( spanish, italian, etc ).

What is the best way to do that ?

I can save a cookie where there is the language but where can I put these translated strings ?

xRobot
  • 25,579
  • 69
  • 184
  • 304
  • 4
    This topic has so, so many questions and articles and best practices and tutorials on Stack Overflow and Google... just a ten-second search away. (But of course, somebody had to upvote this question nevertheless.) – Pekka Jun 01 '12 at 15:09
  • either use a language pack or add google translator to your website. u need to save language selection in cookie and move ahead in this way ur choice – swapnesh Jun 01 '12 at 15:10
  • Try googling `php + i18n` or as pekka suggests, using the handy SO search feature. – prodigitalson Jun 01 '12 at 15:11
  • 1
    possible duplicate of [PHP - how to translate a website into multiple languages?](http://stackoverflow.com/questions/954160/php-how-to-translate-a-website-into-multiple-languages) – Quentin Jun 01 '12 at 15:12
  • 1
    @Pekka It's a wonder this account isn't banned after repeated questions like this and http://stackoverflow.com/questions/3905734/how-to-send-100-000-emails-weekly. One could reverse-engineer all of xRobot's projects by simply reading his question history. I don't think he goes from one problem to the next without posting a question on it. I think this account is almost a case-study about the gray-line between real contributors vs leeches. 341 questions with only 1 answer to his own question.. I honestly can't tell if he doesn't care enough to answer questions or if he doesnt have the ability – Mike B Jun 04 '12 at 15:15

1 Answers1

0

If you don't use a framework like, for instance, symfony2 (that have a component called translation) or Zend (that i'm sure will have some corrispective standalone "component"), a way for achive this is to keep a php file with key=> value pairs (or better, an array) and include that file onto your page. In that way, you could lookup everytime and, then, load the "right" labels and similar ...

Also, symfony2 translation component could be used as a standalone part so take a look if it could satisfy your needs.

DonCallisto
  • 29,419
  • 9
  • 72
  • 100