6

I have a D6 site with several custom modules. The site now needs to support multiple languages.

All my strings are wrapped in t() and I'm pretty familiar with locale.module and the i18n modules. I know that all translatable strings get written to the 'locales_source' table, and that from there I can export a .pot file to send to translators.

What I can't figure out, however, is how I can get all of the translatable strings in my custom modules into the 'locales_source' table. I know that the t() function calls locale(), which in turn will write a newly found string to this table, but how can I make all translatable strings get into the table at once? I think I need a function that will parse the PHP source for t(), watchdog, hook_menu, etc to find everything that's translatable and write it to 'locale_source'...?

4

You can install the Translation template extractor module.

The Translation template extractor provides a web based and a command line Gettext translation template extractor interface for Drupal as well as a reusable API to look for translatable strings and translatability errors. This tool is used under the hood at http://localize.drupal.org/ as well to serve as a parsing machine for Drupal.org project releases.

If you want a user interface that allows you to translate in any language the strings provided by your custom module, then you can install the Localization server.

It provides a generic translation database backend with a community localization user interface, which allows people to collaborate on translating projects to different languages. It currently contains tools to translate Drupal projects as well as general Gettext based sources.

The difference is that the first module allows you to create the translation template files necessary to translate the strings provided by any module running on your server, including any custom module. Those files need to be edited to create the actual translation files that provide the translated strings.
The second module, which depends from the first one, allows to create the translation files using a user interface. While the first module requires you to manually edit the translation template files to obtain the translation files, with the second module you can do it using Drupal.

  • Translation template extractor is exactly what I was looking for. TY! – rcourtna Jul 10 '11 at 3:22
  • Translation template extractor is working great for generating potx files. Any idea how I can get the strings it detects in the locales_source table (so that I can take advantage of locale.module's translation interfaces)? The Import feature Locale provides apparently only imports already-translated strings - quite frustrating... drupal.org/node/361615 – rcourtna Jul 10 '11 at 4:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.