can you get more random?

Symfony: extracting strings from 1.2 forms using i18n:extract

June 9th, 2010 Posted in Uncategorised

Anyone using Sympfony 1.2 will probably have realised by now that the i18n:extract task doesn’t extract strings from any files in lib/form/*

This useful thread shows how to dump all translated strings into a file which can later be parsed by the i18n:extract task, unfortunately it creates huge files, and needs to be disabled in production environments for performance reasons.

After a quick search through the code, I  have patched my code to only dump untranslated strings to the i18n.temp file.

Here’s the patch for lib/vendor/symfony/lib/i18n/sfMessageFormat.class.php

// found, but untranslated
 if (empty($target))
 {
+          file_put_contents(sfConfig::get('sf_app_template_dir').'/i18n.temp.php',"<?php __('$string'); ?>\n",FILE_APPEND);
 return $this->postscript[0].$this->replaceArgs($string, $args).$this->postscript[1];
 }
 return $this->replaceArgs($target, $args);

(I would have posted this in reply to the original comment, but I couldn’t find the original post for some reason)

Share

Post a Comment