메뉴 건너뛰기

조회 수 3494 추천 수 49 댓글 29
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
Extra Form

제가 가진 지식을 나눠드리면 좋을 것 같아 quickbms를 활용한 데이터 분석 강좌를 꾸준히 작성했었지만, 기초편 넘어가니 읽어주시는 분들이 없더군요. 그리고 스크립트 툴 제작 강좌 자체가 없기 때문에 큰 도움될거라 믿고 야심차게 준비했으나.. 한글화 패치 인력이 모인 한식구 카페에서도 읽는 분들이 잘 없는 것 같습니다. ㅠㅠ

 

뭐, 아무튼 누군가에게는 도움이 되길 바랍니다. 궁금한 점이 있으면 질문주세요.

 

소스 코드와 예제 첨부 파일 http://blog.naver.com/physics1114/220958590835

 

바이너리 파일에서 CSV로 추출, 그리고 다시 원본으로 되돌리는 과정입니다.

 

<추출> - 기초편과 비슷한 구조입니다만, 하나의 파일에 여러가지 언어 정보를 담고 있습니다. 하여 임의로 array가 되도록 작성했습니다.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <MsgBoxConstants.au3>

$Path = FileOpenDialog("Select the -25 file", @ScriptDir, "dat files (*.-25)",1)
If @error = 1 Then Exit
$File = fileopen($Path,16)
$Name = CompGetFileName($Path)

FileSetPos($File,"0xF0",0)
$Files = _BinaryToInt32(FileRead($File, 4))

Dim $Text
$Text &= "분류" & @TAB & "영어"& @TAB & "스페인어"& @TAB & "카탈로니아어" & @TAB &"프랑스어" & @TAB & "이탈리아어" & @TAB & "독일어" & @TAB &"일본어" & @TAB & "폴란드어" & @TAB & "헝가리어" & @TAB & "러시아어" & @TAB & "중국어" & @CRLF

Dim $Str
For $i = 1 to $Files
    $Title_pos = FileGetPos($file)
    $Title_len = _BinaryToInt32(FileRead($File, 4))
 $Str = BinaryToString(FileRead($File,$Title_len),4)
 $Text &= $Str & @TAB

    $jump = $Title_len - 4*int($Title_len / 4) ;ex) if $Title_len= 0x13 = 19=> 19 - 4*(19/4) = 19 - 4*4 = 3
    If $jump <> 0 Then
 $jump = 4 - $jump ; 4 - 3 = 1만큼 $Title_pos에서 jump 해야 다음 스트링 len 시작지점
    $offset = $Title_pos + 4 + $Title_len + $jump
    Filesetpos($file,$offset,0)
 EndIf

    $null = FileRead($File, 4)
 $category_pos = FileGetPos($file)
 $category_len = _BinaryToInt32(FileRead($File, 4))

 If $category_len = 0 Then
    $languages = FileRead($File, 4) ; 0x0B000000
 Else
    ;MsgBox(0,"Title",$category_len)
    $category = BinaryToString(FileRead($File,$category_len),4)
    $jump = $category_len - 4*int($category_len / 4) ;ex) if $Title_len= 0x13 = 19=> 19 - 4*(19/4) = 19 - 4*4 = 3
       If $jump <> 0 Then
       $jump = 4 - $jump ; 4 - 3 = 1만큼 $Title_pos에서 jump 해야 다음 스트링 len 시작지점
          $offset = $category_pos + 4 + $category_len + $jump
          Filesetpos($file,$offset,0)
    EndIf
 $languages = FileRead($File, 4) ; 0x0B000000
 EndIf

    For $j = 1 to $languages
 $pos = FileGetPos($File)
 $len = _BinaryToInt32(FileRead($File, 4))
 $Str = BinaryToString(FileRead($File,$len),4)
    $Str = StringRegExpReplace($Str,@CRLF,"<cf>")
 $Str = StringRegExpReplace($Str,@LF,"<lf>")
 $Str = StringRegExpReplace($Str,@CR,"<cr>")
    If $j = 11 Then
       $Text &= $Str & @CRLF
       Else
          $Text &= $Str & @TAB
       EndIf

          $jump_2 = $len - 4*int($len / 4) ;ex) if $Title_len= 0x13 = 19=> 19 - 4*(19/4) = 19 - 4*4 = 3
       If $jump_2 <> 0 Then
       $jump_2 = 4 - $jump_2 ; 4 - 3 = 1만큼 $Title_pos에서 jump 해야 다음 스트링 len 시작지점
          $offset_2 = $pos + 4 + $len + $jump_2
          Filesetpos($file,$offset_2,0)
    EndIf
 Next

    $pos_tail_block = FileGetPos($File)
 $tail_block = FileRead($File, "0x40")
 ;MsgBox(0,"Title",$pos_tail_block)
 Next

;;;Lang category infor
$Tail_pos = FileGetPos($file)
$Tail = FileRead($File, "0xB8")
;;;

$hFile = FileOpen ($Name&".csv", 2+256)
FileWrite($hFile, $Text)
FileClose($hFile)
TrayTip("Exporter", "Finish!", 3)
sleep(3000)

Func CompGetFileName($Path)
If StringLen($Path) < 4 Then Return -1
$ret = StringSplit($Path,"\",2)
If IsArray($ret) Then
Return $ret[UBound($ret)-1]
EndIf
If @error Then Return -1
EndFunc

Func _BinaryToInt32($Binary)
 Return BitAND(Int(Binary($Binary)), 0xFFFFFFFF)
EndFunc

 

이렇게 하여 추출 후, csv 파일을 구글 시트에 업로드합니다.

필요없는 C~G열은 '열 숨기기'로 숨기고, 번역을 진행 한 후 폰트까지 만들어줍니다.

K-020.png

 

<도입> _DelimFile_To_Array2D 함수는 템플릿이니 array 배열 사용할 때 그대로 차용하면 됩니다.

아라가미의 경우 Array 배열이 11이 되도록 추출했으니  $Array = 11로 지정했습니다.

$NEWdata에서 템플릿 함수를 불러오도록 만들고.. 나머지 과정은 제가 만든 소스 코드를 읽어보시면 됩니다.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include <ArrayNaturalSort.au3>
#include <File.au3>
#include <Binary.au3>

Dim $NEWdata, $Num = 2
$Array = 11
$Debug = false

$TxtPath = FileOpenDialog("txt 파일을 선택하세요", @ScriptDir, "txt files (*.csv)",1)
If @error = 1 Then Exit

$NEWdata = _DelimFile_To_Array2D($TxtPath, @TAB, $Array + 1) ; 2 = colums, key + lang1
if $Debug Then _ArrayDisplay($NEWdata)

$Name = StringTrimRight(CompGetFileName($TxtPath),4)
$File = FileOpen($Name, 0+16)
If $File = -1 Then
MsgBox(0,"오류!",$Name & "파일을 열 수 없습니다.")
Exit
EndIf

FileSetPos($File,"0xF0",0)
$Files = _BinaryToInt32(FileRead($File, 4))

FileSetPos($File,0,0)
Dim $New_Block
Dim $Newtext
Dim $tail_block
Dim $Newfile

$New_Header = FileRead($File, "0xF4")
$Newfile &= $New_Header

For $i = 1 to $Files
    $Title_pos = FileGetPos($file)
    $Title_len = _BinaryToInt32(FileRead($File, 4))
    $jump = $Title_len - 4*int($Title_len / 4)

    If $jump = 0 Then
    $size = 4 + $Title_len
 Else
       $jump = 4 - $jump
       $size = 4 + $Title_len + $jump
    EndIf

    Filesetpos($file,$Title_pos,0)
 $Title = FileRead($File, $size)
 $New_Block &= $Title

    $null = FileRead($File, 4)
 $New_Block &= $null

 $category_pos = FileGetPos($file)
 $category_len = _BinaryToInt32(FileRead($File, 4))

 If $category_len = 0 Then
    $New_Block &= "0x00000000"
    $languages = FileRead($File, 4) ; 0x0B000000
       $New_Block &= $languages
    Else
       $category_jump = $category_len - 4*int($category_len / 4)

       If $category_jump = 0 Then
       $category_size = 4 + $category_len
    Else
          $category_jump = 4 - $category_jump
          $category_size = 4 + $category_len + $category_jump
       EndIf

       Filesetpos($file,$category_pos,0)
    $category = FileRead($File, $category_size)

    $New_Block &= $category
    $languages = FileRead($File, 4) ; 0x0B000000
       $New_Block &= $languages
 EndIf

    ;read text
 For $x = 1 to $Array
    $ValueText = $NEWdata[$Num][$x]
    $ValueText = StringRegExpReplace($ValueText,"<cf>",@CRLF)
    $ValueText = StringRegExpReplace($ValueText,"<lf>",@LF)
    $ValueText = StringRegExpReplace($ValueText,"<cr>",@CR)
       $bNewText = StringToBinary($ValueText,4)
    $Newlen_for_cal = BinaryLen($bNewText)
    $Newlen = _binaryFromint32($Newlen_for_cal)
    $Newtext &= $Newlen
    $Newtext &= $bNewText

       $add_null_for_cal = $Newlen_for_cal - 4*int($Newlen_for_cal / 4)
       If $add_null_for_cal <> 0 Then
    $add_null_for_cal = 4 - $add_null_for_cal
    For $k = 1 to $add_null_for_cal
     $Newtext &= "0x00"
    Next
       EndIf
 Next
 $Num += 1
 $New_Block &= $Newtext
 $Newtext = "0x" & StringRegExpReplace($Newtext,"0x","")

    ;read $file in order to bypass language data and get block_tail.
    For $w = 1 to 11
 $pos = FileGetPos($File)
 $len = _BinaryToInt32(FileRead($File, 4))

    $jump = $len - 4*int($len / 4)

    If $jump <> 0 Then
    $jump = 4 - $jump
    $offset = $pos + $len + 4 + $jump
 Else
    $offset = $pos + $len + 4
 EndIf

    FileSetPos($file,$offset,0)
 Next

    $pos_tail_block = FileGetPos($File)


 $tail_block = FileRead($File, "0x40")
    $New_Block &= $tail_block

    $New_Block = "0x" & StringRegExpReplace($New_Block,"0x","")
    $Newfile &= $New_Block

    $New_Block = ""
 $Newtext = ""
 Next

;Lang category infor
$Tail_pos = FileGetPos($file)
$Tail = FileRead($File, "0xFC")
$Newfile &= $Tail
$Newfile = "0x" & StringRegExpReplace($Newfile,"0x","")

$hNewfile = FileOpen ("NEW_"&$Name, 2+16)
FileWrite ($hNewfile, $Newfile)
FileClose ($hNewfile)
TrayTip ("추출", "성공!", 3)
sleep (3000)

Func CompGetFileName($Path)
If StringLen($Path) < 4 Then Return -1
$ret = StringSplit($Path,"\",2)
If IsArray($ret) Then
Return $ret[UBound($ret)-1]
EndIf
If @error Then Return -1
EndFunc

Func _DelimFile_To_Array2D($s_file, $s_delim = @TAB, $i_max_2d = 0)
    Local $s_str = $s_file
    If FileExists($s_str) Then $s_str = FileRead($s_file)

    Local $i_enum_max = False
    If Int($i_max_2d) < 1 Then
        $i_enum_max = True
        $i_max_2d = 1
    EndIf

    Local $a_split = StringSplit(StringStripCR($s_str), @LF)
    Local $a_ret[$a_split[0] + 1][$i_max_2d] = [[$a_split[0]]], $a_delim

    For $i = 1 To $a_split[0]
        $a_delim = StringSplit($a_split[$i], $s_delim, 1)
        If $i_enum_max And $i_max_2d < $a_delim[0] Then
            ReDim $a_ret[$a_split[0] + 1][$a_delim[0]]
            $i_max_2d = $a_delim[0]
        EndIf
        For $j = 1 To $a_delim[0]
            $a_ret[$i][$j - 1] = $a_delim[$j]
        Next
    Next

    Return $a_ret
EndFunc

 

이렇게 하여 리팩을 하면 번역문 길이에 제약받지 않는 한글 패치 제작이 가능해집니다.

여기까지 기본편이고, 기본 응용, 중급, 고급 과정은 따로 강좌를 더 작성할지는 잘 모르겠네요.

아무튼 한글화 도전하시는 분들께 도움이 되길 바랍니다.

20170310004544_1.jpg

 

20170310004531_1.jpg

 

글쓴이 님의 최신글
  1. 2019-08-01 22:00 이야기 > 디스아너드 브릭모어의 마녀들 번역가 모집 *8
  2. 2019-02-02 13:02 이야기 > 니노쿠니2 한글 패치 1.0 배포 *36
  3. 2019-02-01 23:04 이야기 > 히트맨 2016 한글 패치 1.0 배포 *36
  4. 2018-09-09 21:55 이야기 > 게이밍 노트북 어떤게 괜찮을까요? *14
  5. 2018-06-30 14:08 이야기 > 회사 기숙사.. 게임 라이프 접어야할 각인지.. *39


List of Articles
분류 제목 게임 글쓴이 날짜 조회 추천
공지 ITCM <스팀그룹> 비공개 전환 안내 및 초대요청 2334 ITCM 08.24 114489 47
꿀팁 [운영자 인증] ITCM 꿀팁정보 모음 (2017/3/16) 33 코코넛먹자 08.05 116966 68
공지 ITCM 내부 규정 안내 71 file ZardLuck 02.05 96267 89
잡담 스팀 할인 결산 및 도전과제 이벤트 결산 18 file 뫼한 07.06 675 50
잡담 스팀 게임 7K 달성했어요~ 50 file amossong 05.03 841 50
잡담 지금까지 제가 나눔한 게임중 도과 100% 달성한 게임... 88 뫼한 12.27 2165 50
잡담 섣불리 한패를 배포했나란 생각이 좀 드는군요. 17 RuTel 08.26 2076 49
잡담 60초! 한글 패치 11번째 업데이트 버전 배포합니다. 17 프기니 07.04 8924 49
잡담 한글화의 현주소 20 나무노래 05.02 1284 49
잡담 마지막이 될지도 모르는(?) 한글화 스크립트 툴 제작 ... 29 file 프기니 03.15 3494 49
잡담 한글화 스크립트 툴 제작 방법 - 기초편 22 file 프기니 03.08 19114 49
잡담 라이브러리 2K 달성했습니다 :D 36 file 코코넛먹자 03.06 528 49
잡담 SG 부계정 사용하시면 안됩니다 60 file 논현동토토로 02.14 959 49
잡담 나눔한 게임들이 다른게임들로 등록되고 있어요 ㅠㅠ 43 file 푸룬 01.18 539 49
잡담 [팀 한글화의 궤적] 저스트 코즈3 한글 패치 0.9 배포 25 file 프기니 11.17 7834 49
잡담 원피스 해적무쌍3 한글 패치 ver 1.00 배포 29 file 프기니 09.03 2383 49
잡담 Steam 자본주의 게임 축제 무료 아바타, 액자 받으세요 20 file KarlDonitz 01.10 1107 48
잡담 Draugen 한글패치 배포 16 file karania 08.12 1474 48
잡담 원피스 해적무쌍3 검수용 한글 패치 제작 완료 31 file 프기니 08.27 875 48
잡담 1K 달성 신고 합니다. :D 68 file 아레스다 06.30 634 48
잡담 [팀 한글화의 궤적] 아울 보이 한글 패치 1.0 배포 21 file 프기니 01.01 685 48
잡담 12K 34 file 메리코코 05.07 664 47
잡담 다렉 설맞이 할인 가격 모음 29 아레스다 02.09 801 47
잡담 9K 달성했습니다~ 61 file amossong 01.22 608 47
잡담 잇셈에 서식하는 기생충들을 잡았습니다! 27 Nemesis 10.26 1302 47
잡담 SG 레벨 10 달성했어요. :3 33 file Fluffy 07.06 372 47
잡담 디지털 문물의 신(사) 85 file 논현동토토로 11.12 606 47
잡담 둘째가 곧 해군에 입대합니다. 5 file 반백게이머 03.25 754 46
잡담 아울 보이 한글 패치 1.02 배포 84 file 프기니 07.04 983 46
잡담 7분 전이네요 41 file 가쯔나베 05.11 887 46
잡담 몇년간 알바하면서 본 인간군상 40 하임 04.16 1182 46
잡담 어차피 불가능하니 신경쓰지말라는 도전과제를 깼습니... 40 file Nemesis 03.10 840 46
잡담 배너사가 공식 한글화 (베타) 9 file 프기니 02.09 550 46
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 1402 Next
/ 1402
CLOSE

SEARCH

CLOSE