-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathmenu
executable file
·262 lines (242 loc) · 7.2 KB
/
menu
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#!/bin/bash
#
# This file is part of BOSS.
#
# BOSS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BOSS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BOSS. If not, see <http://www.gnu.org/licenses/>.
boss_version="2.3.1"
games=("oblivion" \
"falloutnv" \
"skyrim" \
"fallout3" \
"nehrim")
template_directory="resources/l10n/"
template_file="boss.pot"
wx_locale_path="../wxWidgets/locale/"
languages=("es" \
"ru" \
"zh_CN")
for lang in "${languages[@]}"; do
language_binaries+=("${template_directory}${lang}/LC_MESSAGES/boss.mo")
language_files+=("${template_directory}${lang}/LC_MESSAGES/boss.po")
done
function package_archive() {
local archive_name="boss.zip"
local file_list=("bin/Release-32/boss.exe" \
"bin/Release-32/boss_gui.exe" \
"bin/Release-64/boss.exe" \
"bin/Release-64/boss_gui.exe" \
"data/BOSS.ini" \
"Docs" \
"resources/octokit.js" \
"resources/promise-1.0.0.min.js" \
"resources/style.css" \
"resources/script.js")
for lang in "${languages[@]}"; do
cp -u "${wx_locale_path}${lang}.mo" "${template_directory}${lang}/LC_MESSAGES/wxstd.mo"
language_binaries+=("${template_directory}${lang}/LC_MESSAGES/wxstd.mo")
echo "Copied ${wx_locale_path}${lang}.mo to ${template_directory}${lang}/LC_MESSAGES/wxstd.mo"
done
file_list+=("${language_binaries[@]}")
# TODO(MCP): Rename the directories for the games in the BOSS directory to be consistent with the repository names
for game in "${games[@]}"; do
#game_repos+=("../${game}/.git/config" \
# "../${game}/.git/HEAD" \
# "../${game}/.git/index" \
# "../${game}/.git/packed-refs" \
# "../${game}/.git/refs/heads/master" \
# "../${game}/.git/refs/remotes/origin/HEAD" \
# "../${game}/.git/objects")
mkdir -p "${game}/.git/" \
"${game}/.git/refs/heads/" \
"${game}/.git/refs/remotes/origin/" \
"${game}/.git/objects"
cp -ur "../${game}/.git/config" "${game}/.git/config"
cp -ur "../${game}/.git/HEAD" "${game}/.git/HEAD"
cp -ur "../${game}/.git/index" "${game}/.git/index"
cp -ur "../${game}/.git/packed-refs" "${game}/.git/packed-refs"
cp -ur "../${game}/.git/refs/heads/master" "${game}/.git/refs/heads/master"
cp -ur "../${game}/.git/refs/remotes/origin/HEAD" "${game}/.git/refs/remotes/origin/HEAD"
cp -ur "../${game}/.git/objects" "${game}/.git/objects"
file_list+=("${game}/.git/config" \
"${game}/.git/HEAD" \
"${game}/.git/index" \
"${game}/.git/packed-refs" \
"${game}/.git/refs/heads/master" \
"${game}/.git/refs/remotes/origin/HEAD" \
"${game}/.git/objects")
echo "${game}'s Git files have been copied."
done
zip -r -9 "${archive_name}" "${file_list[@]}"
}
function extract_strings() {
find src/ -type f \( -name '*.cpp' -or -name '*.h' \) \
| xargs xgettext --from-code utf-8 \
--keyword=translate:1,1t \
--keyword=translate:1,2,3t \
--boost \
--indent \
--c++ \
--package-name=BOSS \
--copyright-holder="BOSS Development Team" \
--package-version="${boss_version}" \
--output="${template_file}" \
--output-dir="${template_directory}"
echo "Strings extracted to ${template_directory}${template_file}"
}
function compile_translations(){
for lang in "${languages[@]}"; do
msgfmt --output-file="${template_directory}${lang}/LC_MESSAGES/boss.mo" \
"${template_directory}${lang}/LC_MESSAGES/boss.po"
done
}
function create_new_translation() {
local locale_choice
echo -n "Enter locale (format should be ll<_CC>): "
read locale_choice
echo ""
mkdir -p "${template_directory}${locale_choice}"
msginit --locale="${locale_choice}" \
--input="${template_directory}${template_file}" \
--output-file="${template_directory}${locale_choice}/boss.po"
}
function update_translations() {
for lang in "${language_files[@]}"; do
echo "Udating ${lang}..."
msgmerge --update \
--indent \
--previous \
--quiet \
"${lang}" \
"${template_directory}${template_file}"
done
}
function translation_files_menu() {
local generate_translation_choice=0
until [ "$generate_translation_choice" = "3" ]; do
echo "Generate Translation Files"
echo " 1) Create New Translation"
echo " 2) Update Existing Translation"
echo " 3) Return to Translation Files menu"
echo " 4) Quit"
echo -n "Choice: "
read generate_translation_choice
echo ""
case $generate_translation_choice in
1 \
| "Create New Translation" \
| "create new translation")
create_new_translation
;;
2 \
| "Update Existing Translation" \
| "update existing translation")
update_translations
;;
3 \
| "Return" \
| "return")
generate_translation_choice=3
break
;;
4 \
| "Quit" \
| "quit")
exit
;;
*)
echo "Invalid Option"
;;
esac
done
}
function translation_menu() {
local translation_choice=0
until [ "$translation_choice" = "4" ]; do
echo "Translation Files"
echo " 1) Extract Strings"
echo " 2) Generate Translation Files"
echo " 3) Compile Translation Files"
echo " 4) Return to Main Menu"
echo " 5) Quit"
echo -n "Choice: "
read translation_choice
echo ""
case $translation_choice in
1 \
| "Extract Strings" \
| "extract strings")
# TODO(MCP): Look at replacing some of the values with generated to keep the project consistent?
extract_strings
;;
2 \
| "Generate Translation Files" \
| "generate translation files")
translation_files_menu
;;
3 \
| "Compile Translation Files" \
| "compile translation files")
compile_translations
;;
4 \
| "Return" \
| "return")
translation_choice=4
break
;;
5 \
| "Quit" \
| "quit")
exit
;;
*)
echo "Invalid Option"
;;
esac
done
}
function main() {
local main_choice=0
until [ "$main_choice" = "3" ]; do
echo "Main Menu"
echo " 1) Package Archive"
echo " 2) Translation Files"
echo " 3) Quit"
echo -n "Choice: "
read main_choice
echo ""
case $main_choice in
1 \
| "Package Archive" \
| "package archive")
package_archive
;;
2 \
| "Translation Files" \
| "translation files")
translation_menu
;;
3 \
| "Quit" \
| "quit")
main_choice=3
exit
;;
*)
echo "Invalid Option"
;;
esac
done
}
main "$@"