Previously, I did a tutorial on Kohana 3 internationalization, and promised that I would create a better tool for collecting translations. Here it is:

Kohana-translate is a module for collecting translations. For a how-to on Kohana 3 internationalization, read my tutorial on i18n here. The module was originally based on Langify (by hinton), but:

  • that module used the deprecated Sprig ORM,
  • had a different idea of what the translation files should contain (e.g. key lookups rather than string lookups),
  • did not include user management
  • nor did it support locking translations (meaning that two translators working at the same time would overwrite each other's texts)
  • nor did it deal with a number of niceties, such as:
    • ability to update the translation later from a file,
    • ability to specify which languages to translate to via UI,
    • ability to upload translation files via UI,
    • having a fancy-pants progress bar to motivate translators,
  • and edge cases (multiline string linefeed conversion, UTF8).
So I ended up rewriting all of the code, and am releasing it as Kohana-translate. Get it from Bitbucket: http://bitbucket.org/mixu/kohana-translate (hg clone ssh://[email protected]/mixu/kohana-translate).

Getting started

This is a complete app with all dependencies. It consists of two custom modules - most of the code is under /modules/translate/:
  • user: For user administration, see my auth tutorial.
  • translate: For the translation itself.
Just import backup.sql, fix the database connection settings and you should be set. You will probably also need to create ./application/cache for the cache.
To install into an existing application:
  • Place the module into your module folder + copy the helpers.
  • Add the "translate" and "user" modules to your bootstrap.php file. Note: the "user" module should be required before "auth".
  • Import the backup.sql file into your database.

Comments

Faiyet: Hi, I have built a kohana 3 site on my local machine and I am implementing your kohana-translate plugin. I already added the user and translate folders to my modules folder, hooked them up in bootstrap and configured my database with the necessary information.

At the moment all of the string data is "hardcoded". Do I have to simply call the __("string") wherever I have a string? Do I need to create the language files in the form XX-XX.php under the i18n folder?

Thanks you.

Mikito Takada: Hi Faiyet,

For an overview of how Kohana 3 supports translation, look at http://blog.mixu.net/2010/11/11/kohana-3-i18n-tutorial/

To create the language files I suggest you patch the Kohana i18n to automatically collect the strings for translation:

http://blog.mixu.net/2010/06/02/kohana3-automatically-collect-internationalization-strings/

There might be some updates that are needed if you are using Kohana 3.1 as the code is for Ko3, but there haven't been many big changes...

Sven Walter: Hey, i am using kohana 3.2 and i patched my i18n class... but there are no language strings collected. the write and get methods are called but it seems that there will be no data collected. i am going crazy^^

could you take a look at ko3.2 and youre translation scripts? thx