Changeset 1409
- Timestamp:
- 12/02/06 16:20:46 (2 years ago)
- Location:
- branches/0.11
- Files:
-
- 2 modified
-
samples/app/config/translation.xml (modified) (2 diffs)
-
src/translation/AgaviGettextTranslator.class.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.11/samples/app/config/translation.xml
r1404 r1409 71 71 <message_translator class="AgaviGettextTranslator"> 72 72 <parameters> 73 <parameter name="store_calls">%core.cache_dir%/data</parameter>74 73 <parameter name="text_domains"> 75 74 <parameters> … … 95 94 96 95 </configuration> 96 97 <configuration environment="development"> 98 <translators default_domain="default"> 99 <translator domain="default"> 100 <message_translator class="AgaviGettextTranslator"> 101 <parameter name="store_calls">%core.cache_dir%/data</parameter> 102 <!-- other params are inherited from generic config --> 103 </message_translator> 104 </translator> 105 </translators> 106 </configuration> 107 97 108 </configurations> -
branches/0.11/src/translation/AgaviGettextTranslator.class.php
r1311 r1409 47 47 */ 48 48 protected $pluralFormFunc = null; 49 50 /** 51 * @var bool Whether or not to write a file with all used translations 52 * that can be parsed using xgettext. 53 */ 54 protected $storeTranslationCalls = false; 55 56 /** 57 * @var string The folder to write translation call files to. 58 */ 59 protected $translationCallStoreDir = null; 49 60 50 61 /** … … 69 80 if(isset($parameters['text_domain_pattern'])) { 70 81 $this->domainPathPattern = $parameters['text_domain_pattern']; 82 } 83 84 if(isset($parameters['store_calls'])) { 85 $this->storeTranslationCalls = true; 86 $this->translationCallStoreDir = $parameters['store_calls']; 87 AgaviToolkit::mkdir($parameters['store_calls'], 0777, true); 71 88 } 72 89 } … … 111 128 } 112 129 113 130 // in "devel" mode, write a gettext() or ngettext() call to a file for xgettext parsing 131 if($this->storeTranslationCalls) { 132 file_put_contents( 133 $this->translationCallStoreDir . DIRECTORY_SEPARATOR . $domain . '.php', 134 "" . (is_array($message) ? 135 ('ngettext(' . var_export($message[0], true) . ', ' . var_export($message[1], true) . ', ' . var_export($message[2], true) . ')') : 136 ('gettext(' . var_export($message, true) . ')') 137 ) . ";\n", 138 FILE_APPEND); 139 } 114 140 115 141 if($locale) {

