forked from omegat-org/omegat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SetSvnProperties.java
206 lines (192 loc) · 8.31 KB
/
SetSvnProperties.java
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
/**************************************************************************
OmegaT - Computer Assisted Translation (CAT) tool
with fuzzy matching, translation memory, keyword search,
glossaries, and translation leveraging into updated projects.
Copyright (C) 2008 Alex Buloichik
Home page: http:https://www.omegat.org/
Support center: http:https://groups.yahoo.com/group/OmegaT/
This file is part of OmegaT.
OmegaT 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.
OmegaT 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 this program. If not, see <http:https://www.gnu.org/licenses/>.
**************************************************************************/
package util;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* Set mime properties for all files.
*
* Good reference for mime-types could be found on
* http:https://mindprod.com/jgloss/mime.html
*
* If you are using TortoiseSVN, then kill TSVNCache in memory, since it can
* conflict with command-line svn.
*
* @author Alex Buloichik ([email protected])
*/
public class SetSvnProperties {
protected static String filename;
public static void main(String[] args) {
List<String> files = new ArrayList<String>();
list(new File("."), files);
for (String f : files) {
filename = f.replace('\\', '/');
process();
}
}
protected static void list(File dir, List<String> result) {
File[] files = dir.listFiles();
if (files != null) {
for (File f : files) {
if (!f.isDirectory()) {
result.add(f.getPath());
} else {
list(f, result);
}
}
}
}
protected static void process() {
if (filename.contains("/.svn/") || filename.startsWith("./classes/") || filename.startsWith("./build/")
|| filename.startsWith("./lib-mnemonics/build/") || filename.startsWith("./.settings/")
|| filename.startsWith("./dist")) {
return;
}
if (filename.startsWith("./test/data/")) {
if (filename.endsWith(".xml") || filename.endsWith(".tbx") || filename.endsWith(".srx")) {
set("text/xml");
} else if (filename.endsWith(".hhc") || filename.endsWith(".hhk")) {
set("text/html");
} else if (filename.endsWith(".html")) {
set("text/html");
} else if (filename.endsWith(".ini")) {
set("text/plain");
} else if (filename.endsWith(".odt")) {
set("application/octet-stream");
} else if (filename.endsWith(".docx")) {
set("application/octet-stream");
} else if (filename.endsWith(".po")) {
set("text/plain");
} else if (filename.endsWith(".properties")) {
set("text/plain");
} else if (filename.endsWith(".txt") || filename.endsWith(".tab") || filename.endsWith(".csv")) {
set("text/plain");
} else if (filename.endsWith(".srt")) {
set("text/plain");
} else if (filename.endsWith(".xlf")) {
set("text/xml");
} else if (filename.endsWith(".tmx")) {
set("text/xml", "native");
} else if (filename.endsWith(".wxl")) {
set("text/xml", "native");
} else if (filename.endsWith(".svg")) {
set("text/xml", "native");
} else if (filename.endsWith(".resx")) {
set("text/xml", "native");
} else if (filename.endsWith(".rc")) {
set("text/plain", "native");
} else if (filename.endsWith(".dtd")) {
set("text/plain", "native");
} else if (filename.endsWith(".tex")) {
set("text/plain", "native");
} else if (filename.endsWith(".dz")) {
set("application/gzip");
} else if (filename.endsWith(".idx")) {
set("application/octet-stream");
} else if (filename.endsWith(".ifo")) {
set("text/plain", "native");
} else {
System.out.println("unknown: " + filename);
}
} else if (filename.startsWith("./native/")) {
set("application/octet-stream");
} else if (filename.equals("./release/OmegaT")) {
set("text/plain", "LF");
} else if (filename.startsWith("./.")) {
set("text/xml", "native");
} else if (filename.endsWith(".java")) {
set("text/x-java", "native");
if (filename.contains("./src/")) {
setKeywords("Author Date Id Revision");
}
} else if (filename.equals("./release/l10n-project/omegat.project")) {
set("text/xml", "native");
} else if (filename.endsWith(".properties")) {
set("text/plain", "native");
} else if (filename.endsWith(".xml")) {
set("text/xml", "native");
} else if (filename.endsWith(".jnlp")) {
set("text/xml", "native");
} else if (filename.endsWith(".xsd")) {
set("text/xml", "native");
} else if (filename.endsWith(".dtd")) {
set("text/xml", "native");
} else if (filename.endsWith(".mod")) {
set("text/xml", "native");
} else if (filename.endsWith(".exe")) {
set("application/octet-stream");
} else if (filename.endsWith(".jar")) {
set("application/java-archive");
} else if (filename.endsWith(".zip")) {
set("application/zip");
} else if (filename.endsWith(".gz")) {
set("application/gzip");
} else if (filename.endsWith(".txt")) {
set("text/plain", "native");
} else if (filename.endsWith(".form")) {
set("text/xml", "native");
} else if (filename.endsWith(".ini")) {
set("text/plain", "native");
} else if (filename.endsWith(".bat")) {
set("text/plain", "CRLF");
} else if (filename.endsWith(".cmd")) {
set("text/plain", "CRLF");
} else if (filename.endsWith(".gif")) {
set("image/gif");
} else if (filename.endsWith(".png")) {
set("image/png");
} else if (filename.endsWith(".jpg")) {
set("image/jpeg");
} else if (filename.endsWith(".ico")) {
set("image/x-icon");
} else if (filename.endsWith(".html")) {
set("text/html", "native");
} else if (filename.endsWith(".css")) {
set("text/plain", "native");
} else if (filename.endsWith(".mf")) {
set("text/plain", "native");
} else if (filename.endsWith("/.ignoreme")) {
set("text/plain", "native");
} else if (filename.endsWith(".iss")) {
set("text/plain", "native");
} else if (filename.endsWith(".j2e")) {
set("text/plain", "native");
} else if (filename.endsWith(".odt")) {
set("application/octet-stream");
} else if (filename.endsWith(".vpp")) {
set("application/zip");
} else if (filename.startsWith("./release/OmegaT")) {
set("text/plain");
} else {
System.out.println("unknown: " + filename);
}
}
protected static void set(String mimetype) {
System.out.println("svn propset svn:mime-type " + mimetype + " \"" + filename + "\"");
}
protected static void set(String mimetype, String eol) {
System.out.println("svn propset svn:mime-type " + mimetype + " \"" + filename + "\"");
System.out.println("svn propset svn:eol-style " + eol + " \"" + filename + "\"");
}
protected static void setKeywords(String keywords) {
System.out.println("svn propset svn:keywords '" + keywords + "' \"" + filename + "\"");
}
}