source: client_files/Generate/create_language_file.php

Last change on this file was 61, checked in by george, 16 years ago
  • Přidáno: Export překladů do českého WoW Addonu.
  • Upraveno: Export souborů se nyní ukládá samostatně do složek dle jmen uživatelů.
  • Přidáno: Zobrazování chyb dle konfigurace.
File size: 3.5 KB
Line 
1<?php
2
3session_start();
4include('../../includes/config.php');
5include('../../includes/databaseconection.php');
6include('../../includes/global_function.php');
7
8//připojení do databáze
9$Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password']);
10$Database->SQLCommand('SET NAMES '.$Config['Database']['Charset']);
11$Database->SelectDatabase($Config['Database']['Database']);
12
13if(Licence(LICENCE_ADMIN))
14{ // echo 'Přístup povolen';
15} else die('Přístup zamítnut!');
16
17include ('define.php');
18
19function ReplaceVarInText($string)
20{
21 $string = str_replace('$N', '"..strlower(UnitName("player")).."', $string);
22 $string = str_replace('$n', '"..strlower(UnitName("player")).."', $string);
23 $string = str_replace('$c', '"..strlower(UnitClass("player")).."', $string);
24 $string = str_replace('$C', '"..strlower(UnitClass("player")).."', $string);
25 $string = str_replace('$R', '"..strlower(UnitRace("player")).."', $string);
26 $string = str_replace('$r', '"..strlower(UnitRace("player")).."', $string);
27
28 $string = str_replace('$', '', $string);
29 $string = str_replace(chr(13), '', $string);
30 $string = str_replace(chr(10), '', $string);
31 return($string);
32}
33
34// Funkce na přepsání zlých znaků
35
36function ReplaceEnText($string)
37{
38 // $string = mysql_escape_string($string);
39 $string = strtolower($string);
40 $string = str_replace('$gman:woman;', '"..gsub(gsub(UnitSex("player"), "^2$", "man"), "^3$", "woman").."', $string);
41 $string = str_replace('$g man : woman;', '"..gsub(gsub(UnitSex("player"), "^2$", "man"), "^3$", "woman").."', $string);
42 $string = str_replace('$ghis:her;', '"..gsub(gsub(UnitSex("player"), "^2$", "his"), "^3$", "her").."', $string);
43 $string = str_replace('$g his : her;', '"..gsub(gsub(UnitSex("player"), "^2$", "his"), "^3$", "her").."', $string);
44 $string = str_replace('$glad:lass;', '"..gsub(gsub(UnitSex("lad"), "^2$", "his"), "^3$", "lass").."', $string);
45 $string = str_replace('$g lad : lass;', '"..gsub(gsub(UnitSex("lad"), "^2$", "his"), "^3$", "lass").."', $string);
46
47 $string = str_replace('"', '\"', $string);
48 $string = str_replace('$b$b', ' ', $string);
49 $string = str_replace('$b $b', ' ', $string);
50 $string = str_replace('$b', ' ', $string);
51 $string = str_replace(' ', ' ', $string);
52 $string = ReplaceVarInText($string);
53 return($string);
54}
55
56function ReplaceCzText($string)
57{
58 $string = mysql_escape_string($string);
59 $string = str_replace('$B', '\r\n', $string);
60 $string = str_replace('$b', '\r\n', $string);
61 $string = ReplaceVarInText($string);
62 return($string);
63}
64
65for($j = 0; $j < count($ListFile); $j++)
66{ //hlavní cyklus souborů
67
68 echo $dir_out.$ListFile[$j]['File'].': ';
69 $i = 0;
70
71 $buffer = $ListFile[$j]['Header']; //hlavička souboru
72
73 $sql = $ListFile[$j]['sql'];
74 $ID = $Database->SQLCommand($sql);
75 while ($Line = mysql_fetch_array($ID))
76 {
77 $en = ReplaceEnText($Line['en']);
78 $cz = ReplaceCzText($Line['cz']);
79 if($en <> '' and $cz <> '')
80 {
81 $buffer = $buffer.'
82["'.$en.'"]="'.$cz.'",';
83 $i = $i + 1;
84 }
85 }
86
87 $buffer = $buffer.'
88'.$ListFile[0]['Footer'].'+'.$i.';
89'; //patička souboru
90
91 if($i > 0)
92 {
93 $file_handle = fopen($dir_out.$ListFile[$j]['File'], 'w');
94 $write_result = fwrite($file_handle, $buffer);
95 fclose($file_handle);
96
97 echo('<b>HOTOVO</b><br />');
98 } else echo('<b>ŽÁDNÝ TEXT</b><br />');
99}
100
101?>
Note: See TracBrowser for help on using the repository browser.