TRANSLATING 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. Translating GitPHP
  2. GitPHP uses Gettext for string tokenization. Gettext is a standard
  3. translation system for software. Going into all the details of how
  4. gettext translation works is beyond the scope of this document - this
  5. is just a high-level overview of the steps you need to take to see
  6. GitPHP in your language.
  7. 1. Create a directory in the locale/ directory, named by your locale.
  8. (I'll use en_US as my example throughout - so I'd create directory
  9. locale/en_US)
  10. 2. locale/gitphp.pot contains all the extracted strings from the project,
  11. plus various translation comments I've added. This file is provided by me
  12. and updated anytime new strings are added. To get started, use this file
  13. to initialize a new po file in your locale directory:
  14. msginit --locale=en_US -i locale/gitphp.pot -o locale/en_US/gitphp.po
  15. 3. Translate all of the strings in this file. The easiest way to do this
  16. is by using a po editor. There are quite a few out there - poEdit is a
  17. popular one.
  18. If you're doing this by hand, you will want to make sure all the headers at
  19. the top (Last-Translator, Plural-Forms, etc) are filled correctly, and for
  20. each string, read the english in "msgid" and put the translated string into
  21. "msgstr".
  22. Plural forms which have a "msgid" as well as a "msgid_plural" should have
  23. the singular translated string in msgstr[0] and the plural translated string
  24. in msgstr[1].
  25. Parameters that are passed into the string - for example, dynamic counts or
  26. info from the page itself - appear as %[num] with an optional $[type] behind it,
  27. for example %1 or %2$d. These should stay intact in your string, and the
  28. parameters will be inserted at runtime.
  29. You can look at any of the other existing locales as an example.
  30. Note:
  31. One special string is 'English'. I've made a note for the string, but don't
  32. just translate 'English' into your language. This is the name of YOUR language -
  33. it's displayed as the name of your language in the language picker. You want the
  34. name of your language, in your native language, so speakers of your language
  35. will recognize it without knowing English. For example, in the French locale,
  36. this would be "Français", which is "French" IN French.
  37. 4. Once you're done, save and compile the po into a binary mo. This should
  38. be in the same directory as your po file. So for example, I would compile
  39. locale/en_US/gitphp.po into locale/en_US/gitphp.mo. Most po editors will
  40. do this for you - if not, you can compile it on the command line with the
  41. msgfmt command:
  42. msgfmt -o locale/en_US/gitphp.mo locale/en_US/gitphp.po
  43. 5. Every now and then, as the project's code changes, new strings will come out
  44. or strings will be modified, and your translation will be updated. In this
  45. case, you will need to merge the updates from locale/gitphp.pot into your
  46. translation. You can run this command to see what updates are needed
  47. (the order of parameters is important here):
  48. msgmerge locale/en_US/gitphp.po locale/gitphp.pot
  49. Add the -U flag to do the actual update in your file. All your existing
  50. translations will be left alone, and new strings will be added for you to
  51. translate. A string that was translated already but may have been changed
  52. slightly will be marked "fuzzy" - this means you should evaluate whether the
  53. existing translation is still correct for the changed string. If it's ok
  54. as-is, just mark it as not fuzzy. If it needs to be updated, update it.
  55. After all your updates are done, save and make sure to recompile your mo file.
  56. That's all for translation. As long as your mo file is compiled, it will be
  57. available as a language choice. If you submit your translation po to me, I can
  58. include it with the official distribution and everyone can benefit from it :)