1

Possible Duplicate:
How do you build a multi-language web site?

I inherited some code which is just plain php where I have to do some changes. Because the changes are rather small and the biggest request is support for multi-language, I chosen to keep existing code instead of rewriting it, but I need an i18n library for plain php.

Are there any default library that is used with plain php? I really don't know, a link to usage/download will be really helpful.

Update 1:

It would be nice if you can point me to some console-like tool that helps me build a file with all strings that should be translated, instead of doing it by hand (in CakePHP is every instance between __() function).

Community
  • 1
  • 1
Francesco Belladonna
  • 11,361
  • 12
  • 77
  • 147
  • @hakre: Nope, the answer is completely different from what I'm requesting and here we are talking about php, while there we are talking about java. – Francesco Belladonna Jul 16 '12 at 13:47
  • 1
    I'd say reading helps: http://stackoverflow.com/a/41379/367456 – hakre Jul 16 '12 at 13:48
  • @hakre: Thanks i didn't notice that, well that answer is great, however I don't know if the question **is** actually a duplicate of this because I think it's only a case that there is a php answer there. – Francesco Belladonna Jul 16 '12 at 13:52
  • 1
    The duplicate suggestion is my 2 cents, another of my 2 cents is: gettext works very well and it is fast. it works pretty stand-alone and if you learn about it, it's for other computer languages available, too and a toolchain exists as well as fallback libraries. So it can not get much easier. For your update: Poedit does that `_()` parsing for you. And more tools exist, that's just one/two. – hakre Jul 16 '12 at 13:57
  • @hakre: Thanks a lot, this really helped me. By the way, I think that keeping this question is a good idea for people looking specifically for a php i18n lib, the other is a bit generic and this could help search enginges. Anyway thanks to everyone, this completely solved my issue. – Francesco Belladonna Jul 16 '12 at 14:01
  • Don't worry, marking a question as a (possible) duplicate does not delete it. – hakre Jul 16 '12 at 14:02
  • 1
    @hakre: This is by no means a duplicate of the other question. While the answers might be similar (gettext), the *question* itself is totally different (it's about PHP, not Java) and that's what counts. – Niklas B. Jul 16 '12 at 14:44
  • I can't believe this has been voted as exact duplicate, we are talking about 2 completely different language. – Francesco Belladonna Jul 17 '12 at 15:49

2 Answers2

6

intl(since php 5.3) and gettext(since forever)

From php intl extension docs page:

Internationalization extension (further is referred as Intl) is a wrapper for ICU library, enabling PHP programmers to perform UCA-conformant collation and date/time/number/currency formatting in their scripts.

From gettext docs page:

This package offers to programmers, translators and even users, a well integrated set of tools and documentation. Specifically, the GNU gettext utilities are a set of tools that provides a framework within which other free packages may produce multi-lingual messages.

Sergey Eremin
  • 10,994
  • 2
  • 38
  • 44
  • Why should I choose one or another? Also, are there any helpful console command (like cake) that build a locales file with all instances of my should-be-translated strings? – Francesco Belladonna Jul 16 '12 at 13:48
  • You should choose both not one or another. Also there are helpful console commands if you install gettext on your computer. yes yes. but well, reading helps. :) – hakre Jul 16 '12 at 13:50
  • 4
    They are for different things. Intl - for output of dates/currency/transliteration/formatting numbers in a localized way. gettext is for translation. – Sergey Eremin Jul 16 '12 at 13:51
  • @kgb: Thanks, that's important! I should use both so. – Francesco Belladonna Jul 16 '12 at 13:57
2

gettext is the default PHP i18n extension using the very ubiquitous gettext system.

deceze
  • 510,633
  • 85
  • 743
  • 889