메뉴 건너뛰기

조회 수 3487 추천 수 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 114219 47
꿀팁 [운영자 인증] ITCM 꿀팁정보 모음 (2017/3/16) 33 코코넛먹자 08.05 116799 68
공지 ITCM 내부 규정 안내 71 file ZardLuck 02.05 96106 89
잡담 나겜에 파견나와 근무하고 있는 썬업이 현 상황에 대... 썬업 07.11 697 51
잡담 이제 57살이 되었네요. 14 반백게이머 06.14 1322 50
소개 유니티 우리말화 도구(UnityL10nTool; 베타) 배포 13 file 최낙원 11.08 6865 50
잡담 니노쿠니2 한글화 테스트 결과입니다 17 file 프기니 03.25 1265 50
잡담 한패 보람이 느껴지네요. 4 file RuTel 10.21 839 50
소개 Distrust 한글화 완료되었네요. 28 file 트림 10.01 2791 50
잡담 The Escapists 2 도 한글화 완료했습니다 18 시리시안 09.01 8832 50
잡담 스팀 할인 결산 및 도전과제 이벤트 결산 18 file 뫼한 07.06 675 50
잡담 스팀 게임 7K 달성했어요~ 50 file amossong 05.03 841 50
소개 Hue 한글 패치 1.0 배포 23 file Fluffy 04.02 2530 50
소개 솔트 앤 생츄어리 한국어판을 출시하였습니다. 15 file 미리칸 03.10 882 50
잡담 지금까지 제가 나눔한 게임중 도과 100% 달성한 게임... 88 뫼한 12.27 2165 50
소개 12월 교보eBook의 선물 - 코너스톤 전집 총 40권 22 file 아레스다 12.13 971 50
소개 ☞ 뉴 ITCM 소감 이벤트 [~7월 10일까지] 99 file ZardLuck 07.05 2223 50
일상 회사가 망했으요... 39 뫼한 06.30 956 50
소개 아틀리에 토토리, 한글패치 배포 36 file RuTel 06.09 27475 49
소개 Celeste (셀레스트) 한글 패치 배포 18 file LSW 02.07 3107 49
소개 Tokyo 42 (도쿄 42) 한글 패치 배포 6 file 삼각식빵 01.04 1328 49
잡담 섣불리 한패를 배포했나란 생각이 좀 드는군요. 17 RuTel 08.26 2075 49
잡담 60초! 한글 패치 11번째 업데이트 버전 배포합니다. 17 프기니 07.04 8924 49
잡담 한글화의 현주소 20 나무노래 05.02 1284 49
잡담 마지막이 될지도 모르는(?) 한글화 스크립트 툴 제작 ... 29 file 프기니 03.15 3487 49
잡담 한글화 스크립트 툴 제작 방법 - 기초편 22 file 프기니 03.08 19100 49
잡담 라이브러리 2K 달성했습니다 :D 36 file 코코넛먹자 03.06 528 49
잡담 SG 부계정 사용하시면 안됩니다 60 file 논현동토토로 02.14 959 49
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 ... 2766 Next
/ 2766
CLOSE

SEARCH

CLOSE