0

Does anybody know if the standard php gettext does slow down the web application?

If the .po file always had to be read, it would get really slow I guess. So I thought the technique used might be different (Caching? How does it work?). Could somebody please explain how gettext works in PHP from the performance point of view?

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
  • 2
    *Of course* it will slow it down, doing something takes time while not doing it doesn't take any time. The real questions are different. Most importantly, does the performance impact matter to you? The only way to know is to try it out. Also important: If you need it and it's unacceptably slow, could you do it significantly faster? –  Oct 26 '11 at 19:14
  • **"doing something takes time while not doing it doesn't take any time"**: This is not correct. At least if you mean only the runtime. Just think about the preprocessor in C. At runtime it doesn't take time. Simmilar, I thought it could be possible that PHP could create preprocessed PHP files, where constant statements like (7-5) or "if(true or false)" get converted to an easier statement. – Martin Thoma Oct 28 '11 at 09:07

1 Answers1

3

From my own experience translating an English web application with about ~300 unique strings to Chinese: I did not notice much of a difference. It felt just as snappy.

I guess before you optimize prematurely based on guesses, you should check if it's actually a problem in your specific setup.

BTW: the .po file is actually not parsed every time, it is translated into a binary .mo file

middus
  • 9,103
  • 1
  • 31
  • 33