Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9a9186a2
提交
9a9186a2
authored
8月 10, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
be1fb4db
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
80 行增加
和
30 行删除
+80
-30
SortedProperties.java
h2/src/main/org/h2/util/SortedProperties.java
+1
-0
PrepareTranslation.java
h2/src/tools/org/h2/tools/i18n/PrepareTranslation.java
+4
-30
PropertiesToUTF8.java
h2/src/tools/org/h2/tools/i18n/PropertiesToUTF8.java
+75
-0
没有找到文件。
h2/src/main/org/h2/util/SortedProperties.java
浏览文件 @
9a9186a2
...
...
@@ -22,4 +22,5 @@ public class SortedProperties extends Properties {
Collections
.
sort
(
v
);
return
v
.
elements
();
}
}
h2/src/tools/org/h2/tools/i18n/PrepareTranslation.java
浏览文件 @
9a9186a2
...
...
@@ -4,9 +4,6 @@
*/
package
org
.
h2
.
tools
.
i18n
;
import
java.io.BufferedWriter
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
...
...
@@ -14,10 +11,8 @@ import java.io.FileReader;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.LineNumberReader
;
import
java.io.OutputStream
;
import
java.io.OutputStreamWriter
;
import
java.io.PrintWriter
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.Properties
;
...
...
@@ -286,7 +281,7 @@ public class PrepareTranslation {
// }
}
new
File
(
target
+
"/"
+
MAIN_LANGUAGE
).
mkdirs
();
storeProperties
(
prop
,
target
+
"/"
+
MAIN_LANGUAGE
+
"/"
+
documentName
+
"_"
+
MAIN_LANGUAGE
+
".properties"
);
PropertiesToUTF8
.
storeProperties
(
prop
,
target
+
"/"
+
MAIN_LANGUAGE
+
"/"
+
documentName
+
"_"
+
MAIN_LANGUAGE
+
".properties"
);
String
t
=
template
.
toString
();
if
(
templateIsCopy
&&
!
t
.
equals
(
xml
))
{
for
(
int
i
=
0
;
i
<
Math
.
min
(
t
.
length
(),
xml
.
length
());
i
++)
{
...
...
@@ -340,12 +335,12 @@ public class PrepareTranslation {
Properties
p
=
FileUtils
.
loadProperties
(
main
.
getAbsolutePath
());
Properties
base
=
FileUtils
.
loadProperties
(
baseDir
+
"/"
+
main
.
getName
());
storeProperties
(
p
,
main
.
getAbsolutePath
());
PropertiesToUTF8
.
storeProperties
(
p
,
main
.
getAbsolutePath
());
for
(
int
i
=
0
;
i
<
translations
.
size
();
i
++)
{
File
trans
=
(
File
)
translations
.
get
(
i
);
prepare
(
p
,
base
,
trans
);
}
storeProperties
(
p
,
baseDir
+
"/"
+
main
.
getName
());
PropertiesToUTF8
.
storeProperties
(
p
,
baseDir
+
"/"
+
main
.
getName
());
}
private
static
void
prepare
(
Properties
main
,
Properties
base
,
File
trans
)
...
...
@@ -393,27 +388,6 @@ public class PrepareTranslation {
p
.
remove
(
key
);
}
}
storeProperties
(
p
,
trans
.
getAbsolutePath
());
}
static
void
storeProperties
(
Properties
p
,
String
fileName
)
throws
IOException
{
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
p
.
store
(
out
,
null
);
ByteArrayInputStream
in
=
new
ByteArrayInputStream
(
out
.
toByteArray
());
InputStreamReader
reader
=
new
InputStreamReader
(
in
,
"ISO8859-1"
);
LineNumberReader
r
=
new
LineNumberReader
(
reader
);
FileWriter
w
=
new
FileWriter
(
fileName
);
PrintWriter
writer
=
new
PrintWriter
(
new
BufferedWriter
(
w
));
while
(
true
)
{
String
line
=
r
.
readLine
();
if
(
line
==
null
)
{
break
;
}
if
(!
line
.
startsWith
(
"#"
))
{
writer
.
println
(
line
);
}
}
writer
.
close
();
PropertiesToUTF8
.
storeProperties
(
p
,
trans
.
getAbsolutePath
());
}
}
h2/src/tools/org/h2/tools/i18n/PropertiesToUTF8.java
浏览文件 @
9a9186a2
...
...
@@ -4,16 +4,27 @@
*/
package
org
.
h2
.
tools
.
i18n
;
import
java.io.BufferedWriter
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.LineNumberReader
;
import
java.io.OutputStreamWriter
;
import
java.io.PrintWriter
;
import
java.io.RandomAccessFile
;
import
java.util.Enumeration
;
import
java.util.Properties
;
import
org.h2.tools.code.CheckTextFiles
;
import
org.h2.tools.indexer.HtmlConverter
;
import
org.h2.util.FileUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.SortedProperties
;
import
org.h2.util.StringUtils
;
public
class
PropertiesToUTF8
{
...
...
@@ -22,6 +33,49 @@ public class PropertiesToUTF8 {
convert
(
"bin/org/h2/server/web/res"
,
"."
);
}
private
static
void
propertiesToTextUTF8
(
String
source
,
String
target
)
throws
Exception
{
Properties
prop
=
FileUtils
.
loadProperties
(
source
);
FileOutputStream
out
=
new
FileOutputStream
(
target
);
PrintWriter
writer
=
new
PrintWriter
(
new
OutputStreamWriter
(
out
,
"UTF-8"
));
// keys is sorted
for
(
Enumeration
en
=
prop
.
keys
();
en
.
hasMoreElements
();
)
{
String
key
=
(
String
)
en
.
nextElement
();
String
value
=
prop
.
getProperty
(
key
,
null
);
writer
.
println
(
"@"
+
key
);
writer
.
println
(
value
);
writer
.
println
();
}
writer
.
close
();
}
private
static
void
textUTF8ToProperties
(
String
source
,
String
target
)
throws
Exception
{
LineNumberReader
reader
=
new
LineNumberReader
(
new
InputStreamReader
(
new
FileInputStream
(
source
),
"UTF-8"
));
Properties
prop
=
new
SortedProperties
();
StringBuffer
buff
=
new
StringBuffer
();
String
key
=
null
;
while
(
true
)
{
String
line
=
reader
.
readLine
().
trim
();
if
(
line
==
null
)
{
break
;
}
if
(
line
.
startsWith
(
"@"
))
{
if
(
key
!=
null
)
{
prop
.
setProperty
(
key
,
buff
.
toString
());
buff
.
setLength
(
0
);
}
}
else
{
if
(
buff
.
length
()
>
0
)
{
buff
.
append
(
System
.
getProperty
(
"line.separator"
));
}
buff
.
append
(
line
);
}
}
if
(
key
!=
null
)
{
prop
.
setProperty
(
key
,
buff
.
toString
());
}
storeProperties
(
prop
,
target
);
}
private
static
void
convert
(
String
source
,
String
target
)
throws
Exception
{
File
[]
list
=
new
File
(
source
).
listFiles
();
for
(
int
i
=
0
;
list
!=
null
&&
i
<
list
.
length
;
i
++)
{
...
...
@@ -53,4 +107,25 @@ public class PropertiesToUTF8 {
}
}
static
void
storeProperties
(
Properties
p
,
String
fileName
)
throws
IOException
{
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
p
.
store
(
out
,
null
);
ByteArrayInputStream
in
=
new
ByteArrayInputStream
(
out
.
toByteArray
());
InputStreamReader
reader
=
new
InputStreamReader
(
in
,
"ISO8859-1"
);
LineNumberReader
r
=
new
LineNumberReader
(
reader
);
FileWriter
w
=
new
FileWriter
(
fileName
);
PrintWriter
writer
=
new
PrintWriter
(
new
BufferedWriter
(
w
));
while
(
true
)
{
String
line
=
r
.
readLine
();
if
(
line
==
null
)
{
break
;
}
if
(!
line
.
startsWith
(
"#"
))
{
writer
.
println
(
line
);
}
}
writer
.
close
();
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论