Changeset 73 for trunk/addon/make.php


Ignore:
Timestamp:
Feb 7, 2009, 12:58:56 AM (16 years ago)
Author:
george
Message:
  • Opraveno: Generování kódu $g pro rody v addonu, nadbytečné mezery u generované anglické části addonu a správný překlad odřádkování na symboly \r\n.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/addon/make.php

    r61 r73  
    88*/
    99
     10// Replace special codes by lua functions
    1011function ReplaceVarInText($string)
    1112{
    1213  $string = str_replace('$N', '"..strlower(UnitName("player")).."', $string);
    1314  $string = str_replace('$n', '"..strlower(UnitName("player")).."', $string);
     15  $string = str_replace('$C', '"..strlower(UnitClass("player")).."', $string);
    1416  $string = str_replace('$c', '"..strlower(UnitClass("player")).."', $string);
    15   $string = str_replace('$C', '"..strlower(UnitClass("player")).."', $string);
    1617  $string = str_replace('$R', '"..strlower(UnitRace("player")).."', $string);
    1718  $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  }
    1842
    1943  $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);
    2246  return($string);     
    2347}
     
    2751  //    $string = mysql_escape_string($string);
    2852  $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 
    3654  $string = str_replace('"', '\"', $string);
    3755  $string = str_replace('$b$b', ' ', $string); 
    3856  $string = str_replace('$b $b', ' ', $string);         
    3957  $string = str_replace('$b', ' ', $string);   
    40   $string = str_replace('  ', ' ', $string);
     58  while(strpos($string, '  '))
     59    $string = str_replace('  ', ' ', $string);
    4160  $string = ReplaceVarInText($string); 
    4261  return($string);
     
    144163  while($Line = mysql_fetch_array($DbResult))
    145164  {
    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";
    147166  }
    148167  file_put_contents($TempDir.'LocalizationStrings.lua', $Buffer);
Note: See TracChangeset for help on using the changeset viewer.