Changeset 73 for trunk/addon/make.php
- Timestamp:
- Feb 7, 2009, 12:58:56 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/addon/make.php
r61 r73 8 8 */ 9 9 10 // Replace special codes by lua functions 10 11 function ReplaceVarInText($string) 11 12 { 12 13 $string = str_replace('$N', '"..strlower(UnitName("player")).."', $string); 13 14 $string = str_replace('$n', '"..strlower(UnitName("player")).."', $string); 15 $string = str_replace('$C', '"..strlower(UnitClass("player")).."', $string); 14 16 $string = str_replace('$c', '"..strlower(UnitClass("player")).."', $string); 15 $string = str_replace('$C', '"..strlower(UnitClass("player")).."', $string);16 17 $string = str_replace('$R', '"..strlower(UnitRace("player")).."', $string); 17 18 $string = str_replace('$r', '"..strlower(UnitRace("player")).."', $string); 19 $Gender = '$G'; 20 while(strpos($string, $Gender) !== false) 21 { 22 $Before = substr($string, 0, strpos($string, $Gender)); 23 $Man = substr($string, strpos($string, $Gender) + 2); 24 $Woman = substr($Man, strpos($Man, ':') + 1); 25 $After = substr($Woman, strpos($Woman, ';') + 1); 26 $Man = substr($Man, 0, strpos($Man, ':')); 27 $Woman = substr($Woman, 0, strpos($Woman, ';')); 28 $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'. 29 $Man.'"), "^3$", "'.$Woman.'").."'.$After; 30 } 31 $Gender = '$g'; 32 while(strpos($string, $Gender) !== false) 33 { 34 $Before = substr($string, 0, strpos($string, $Gender)); 35 $Man = substr($string, strpos($string, $Gender) + 2); 36 $Woman = substr($Man, strpos($Man, ':') + 1); 37 $After = substr($Woman, strpos($Woman, ';') + 1); 38 $Man = substr($Man, 0, strpos($Man, ':')); 39 $Woman = substr($Woman, 0, strpos($Woman, ';')); 40 $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'.$Man.'"), "^3$", "'.$Woman.'").."'.$After; 41 } 18 42 19 43 $string = str_replace('$', '', $string); 20 $string = str_replace( chr(13), '', $string);21 $string = str_replace( chr(10), '', $string);44 $string = str_replace("\r", '', $string); 45 $string = str_replace("\n", '\r\n', $string); 22 46 return($string); 23 47 } … … 27 51 // $string = mysql_escape_string($string); 28 52 $string = strtolower($string); 29 $string = str_replace('$gman:woman;', '"..gsub(gsub(UnitSex("player"), "^2$", "man"), "^3$", "woman").."', $string); 30 $string = str_replace('$g man : woman;', '"..gsub(gsub(UnitSex("player"), "^2$", "man"), "^3$", "woman").."', $string); 31 $string = str_replace('$ghis:her;', '"..gsub(gsub(UnitSex("player"), "^2$", "his"), "^3$", "her").."', $string); 32 $string = str_replace('$g his : her;', '"..gsub(gsub(UnitSex("player"), "^2$", "his"), "^3$", "her").."', $string); 33 $string = str_replace('$glad:lass;', '"..gsub(gsub(UnitSex("lad"), "^2$", "his"), "^3$", "lass").."', $string); 34 $string = str_replace('$g lad : lass;', '"..gsub(gsub(UnitSex("lad"), "^2$", "his"), "^3$", "lass").."', $string); 35 53 36 54 $string = str_replace('"', '\"', $string); 37 55 $string = str_replace('$b$b', ' ', $string); 38 56 $string = str_replace('$b $b', ' ', $string); 39 57 $string = str_replace('$b', ' ', $string); 40 $string = str_replace(' ', ' ', $string); 58 while(strpos($string, ' ')) 59 $string = str_replace(' ', ' ', $string); 41 60 $string = ReplaceVarInText($string); 42 61 return($string); … … 144 163 while($Line = mysql_fetch_array($DbResult)) 145 164 { 146 $Buffer .= 'f("'.addslashes($Line['id_text']).'", "'. addslashes($Line['Original']).'", "'.addslashes($Line['Translation']).'");'."\n";165 $Buffer .= 'f("'.addslashes($Line['id_text']).'", "'.str_replace("\n", '\r\\', addslashes($Line['Original'])).'", "'.str_replace("\n", '\r\\', addslashes($Line['Translation'])).'");'."\n"; 147 166 } 148 167 file_put_contents($TempDir.'LocalizationStrings.lua', $Buffer);
Note:
See TracChangeset
for help on using the changeset viewer.