Annotation of /mambo/branches/4.6/includes/phpgettext/phpgettext.message.php
Parent Directory
|
Revision Log
Revision 39 - (view) (download)
| 1 : | csouza | 39 | <?php |
| 2 : | /** | ||
| 3 : | * @version 0.9 | ||
| 4 : | * @author Carlos Souza | ||
| 5 : | * @copyright Copyright (c) 2005 Carlos Souza <csouza@web-sense.net> | ||
| 6 : | * @package PHPGettext | ||
| 7 : | * @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
| 8 : | * @link http://phpgettext.web-sense.net | ||
| 9 : | * | ||
| 10 : | * | ||
| 11 : | */ | ||
| 12 : | |||
| 13 : | |||
| 14 : | class PHPGettext_Message | ||
| 15 : | { | ||
| 16 : | // --- ATTRIBUTES --- | ||
| 17 : | /** | ||
| 18 : | * Short description of attribute comments | ||
| 19 : | * | ||
| 20 : | * @access public | ||
| 21 : | * @var int | ||
| 22 : | */ | ||
| 23 : | var $comments = array(); | ||
| 24 : | |||
| 25 : | /** | ||
| 26 : | * Short description of attribute is_fuzzy | ||
| 27 : | * | ||
| 28 : | * @access public | ||
| 29 : | * @var int | ||
| 30 : | */ | ||
| 31 : | var $is_fuzzy = false; | ||
| 32 : | |||
| 33 : | /** | ||
| 34 : | * Short description of attribute msgid | ||
| 35 : | * | ||
| 36 : | * @access public | ||
| 37 : | * @var int | ||
| 38 : | */ | ||
| 39 : | var $msgid = ''; | ||
| 40 : | |||
| 41 : | /** | ||
| 42 : | * Short description of attribute msgid | ||
| 43 : | * | ||
| 44 : | * @access public | ||
| 45 : | * @var int | ||
| 46 : | */ | ||
| 47 : | var $msgid_plural = ''; | ||
| 48 : | |||
| 49 : | /** | ||
| 50 : | * Short description of attribute msgstr | ||
| 51 : | * | ||
| 52 : | * @access public | ||
| 53 : | * @var int | ||
| 54 : | */ | ||
| 55 : | var $msgstr = ''; | ||
| 56 : | |||
| 57 : | // --- OPERATIONS --- | ||
| 58 : | |||
| 59 : | /** | ||
| 60 : | * Short description of method PHPGettext_Catalog_Entry | ||
| 61 : | * | ||
| 62 : | * @access public | ||
| 63 : | * @author firstname and lastname of author, <author@example.org> | ||
| 64 : | * @param void | ||
| 65 : | * @param void | ||
| 66 : | * @return void | ||
| 67 : | */ | ||
| 68 : | function PHPGettext_Message($msgid = "", $msgid_plural = '') | ||
| 69 : | { | ||
| 70 : | $this->msgid = $msgid; | ||
| 71 : | $this->msgid_plural = $msgid_plural; | ||
| 72 : | } | ||
| 73 : | |||
| 74 : | /** | ||
| 75 : | * Short description of method setmsgstr | ||
| 76 : | * | ||
| 77 : | * @access public | ||
| 78 : | * @author firstname and lastname of author, <author@example.org> | ||
| 79 : | * @param void | ||
| 80 : | * @return void | ||
| 81 : | */ | ||
| 82 : | function setmsgstr($msgstr) | ||
| 83 : | { | ||
| 84 : | $this->msgstr = $msgstr; | ||
| 85 : | } | ||
| 86 : | |||
| 87 : | /** | ||
| 88 : | * Short description of method setFuzzy | ||
| 89 : | * | ||
| 90 : | * @access public | ||
| 91 : | * @author firstname and lastname of author, <author@example.org> | ||
| 92 : | * @param void | ||
| 93 : | * @return void | ||
| 94 : | */ | ||
| 95 : | function setfuzzy($is_fuzzy = true) | ||
| 96 : | { | ||
| 97 : | $this->is_fuzzy = ($is_fuzzy) ? true : false; | ||
| 98 : | } | ||
| 99 : | |||
| 100 : | /** | ||
| 101 : | * Short description of method setComments | ||
| 102 : | * | ||
| 103 : | * @access public | ||
| 104 : | * @author firstname and lastname of author, <author@example.org> | ||
| 105 : | * @param void | ||
| 106 : | * @return void | ||
| 107 : | */ | ||
| 108 : | function setcomments($comments) | ||
| 109 : | { | ||
| 110 : | if (is_array($comments)) | ||
| 111 : | return $this->comments = $comments; | ||
| 112 : | |||
| 113 : | return false; | ||
| 114 : | } | ||
| 115 : | |||
| 116 : | /** | ||
| 117 : | * Short description of method reset | ||
| 118 : | * | ||
| 119 : | * @access public | ||
| 120 : | * @author firstname and lastname of author, <author@example.org> | ||
| 121 : | * @param void | ||
| 122 : | * @return void | ||
| 123 : | */ | ||
| 124 : | function reset($property = 'all') | ||
| 125 : | { | ||
| 126 : | switch ($property) | ||
| 127 : | { | ||
| 128 : | case 'comments': | ||
| 129 : | unset($this->comments); | ||
| 130 : | break; | ||
| 131 : | case 'is_fuzzy': | ||
| 132 : | unset($this->fuzzy); | ||
| 133 : | break; | ||
| 134 : | case 'msgid': | ||
| 135 : | unset($this->msgid); | ||
| 136 : | break; | ||
| 137 : | case 'msgstr': | ||
| 138 : | unset($this->msgstr); | ||
| 139 : | break; | ||
| 140 : | case 'all': | ||
| 141 : | default: | ||
| 142 : | unset($this->comments); | ||
| 143 : | unset($this->is_fuzzy); | ||
| 144 : | unset($this->msgid); | ||
| 145 : | unset($this->msgstr); | ||
| 146 : | break; | ||
| 147 : | } | ||
| 148 : | } | ||
| 149 : | |||
| 150 : | |||
| 151 : | /** | ||
| 152 : | * Short description of method toString | ||
| 153 : | * | ||
| 154 : | * @access public | ||
| 155 : | * @author firstname and lastname of author, <author@example.org> | ||
| 156 : | * @return void | ||
| 157 : | */ | ||
| 158 : | function toString() | ||
| 159 : | { | ||
| 160 : | $string = ''; | ||
| 161 : | // comments | ||
| 162 : | if (count($this->comments > 0)) { | ||
| 163 : | foreach ($this->comments as $comment){ | ||
| 164 : | if (preg_match('/fuzzy/', $comment)) { | ||
| 165 : | $string .= trim($comment)."\n"; | ||
| 166 : | } | ||
| 167 : | if (strncmp($comment, "#:", 2) == 0) { | ||
| 168 : | $string .= trim($comment)."\n"; | ||
| 169 : | } | ||
| 170 : | // fuzzy entries | ||
| 171 : | if ($this->is_fuzzy) { | ||
| 172 : | $string .= "#, fuzzy\n"; | ||
| 173 : | } | ||
| 174 : | } | ||
| 175 : | } | ||
| 176 : | |||
| 177 : | // msgid | ||
| 178 : | if (strpos($this->msgid, "\n") > 0) { | ||
| 179 : | $string .= "msgid \"\"\n"; | ||
| 180 : | $msgid = explode("\n", $this->msgid); | ||
| 181 : | foreach ($msgid as $line) | ||
| 182 : | $string .= "\"$line\\n\"\n"; | ||
| 183 : | } else { | ||
| 184 : | $string .= "msgid \"$this->msgid\"\n"; | ||
| 185 : | } | ||
| 186 : | |||
| 187 : | if (isset($this->msgid_plural)) { | ||
| 188 : | $string .= "msgid_plural \"$this->msgid_plural\"\n"; | ||
| 189 : | } | ||
| 190 : | // msgstr | ||
| 191 : | if (strpos($this->msgstr, "\n") > 0) { | ||
| 192 : | $string .= "msgstr \"\"\n"; | ||
| 193 : | $msgstr = explode("\n", $this->msgstr); | ||
| 194 : | foreach ($msgstr as $line) | ||
| 195 : | $string .= "\"$line\\n\"\n"; | ||
| 196 : | $string .= "\n"; | ||
| 197 : | } // plurals | ||
| 198 : | elseif (is_array($this->msgstr)){ | ||
| 199 : | |||
| 200 : | foreach ($this->msgstr as $k => $msgstr) { | ||
| 201 : | $string .= "msgstr[$k] \"$msgstr\"\n"; | ||
| 202 : | } | ||
| 203 : | $string .= "\n"; | ||
| 204 : | } else { | ||
| 205 : | $string .= "msgstr \"$this->msgstr\"\n\n"; | ||
| 206 : | } | ||
| 207 : | return $string; | ||
| 208 : | } | ||
| 209 : | |||
| 210 : | } /* end of class PHPGettext_Catalog_Entry */ | ||
| 211 : | |||
| 212 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

