Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
1556258b
提交
1556258b
authored
8月 03, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
81c34acc
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
65 行增加
和
23 行删除
+65
-23
XMLParser.java
h2/src/tools/org/h2/tools/doc/XMLParser.java
+14
-7
PrepareTranslation.java
h2/src/tools/org/h2/tools/i18n/PrepareTranslation.java
+51
-16
没有找到文件。
h2/src/tools/org/h2/tools/doc/XMLParser.java
浏览文件 @
1556258b
...
...
@@ -27,6 +27,7 @@ public class XMLParser {
private
int
index
;
private
int
eventType
;
private
String
currentText
;
private
String
currentToken
;
private
String
prefix
,
localName
;
private
String
[]
attributeValues
=
new
String
[
3
];
private
int
currentAttribute
;
...
...
@@ -83,18 +84,15 @@ public class XMLParser {
private
void
read
()
{
currentText
=
null
;
currentAttribute
=
0
;
int
currentStart
=
index
;
int
tokenStart
=
index
,
currentStart
=
index
;
int
ch
=
readChar
();
if
(
ch
<
0
)
{
eventType
=
END_DOCUMENT
;
return
;
}
if
(
ch
==
'<'
)
{
}
else
if
(
ch
==
'<'
)
{
currentStart
=
index
;
ch
=
readChar
();
if
(
ch
<
0
)
{
eventType
=
ERROR
;
return
;
}
else
if
(
ch
==
'?'
)
{
eventType
=
PROCESSING_INSTRUCTION
;
currentStart
=
index
;
...
...
@@ -108,10 +106,12 @@ public class XMLParser {
}
}
if
(
xml
.
substring
(
currentStart
).
startsWith
(
"xml"
))
{
int
back
=
tokenStart
;
read
();
return
;
}
tokenStart
=
back
;
}
else
{
currentText
=
xml
.
substring
(
currentStart
,
index
-
1
);
}
}
else
if
(
ch
==
'!'
)
{
ch
=
readChar
();
if
(
ch
==
'-'
)
{
...
...
@@ -224,6 +224,7 @@ public class XMLParser {
}
}
}
else
{
// TODO need to replace &#xx;?
eventType
=
CHARACTERS
;
while
(
true
)
{
ch
=
readChar
();
...
...
@@ -236,6 +237,7 @@ public class XMLParser {
}
currentText
=
xml
.
substring
(
currentStart
,
index
);
}
currentToken
=
xml
.
substring
(
tokenStart
,
index
);
}
private
void
readAttributeValues
()
{
...
...
@@ -302,6 +304,7 @@ public class XMLParser {
if
(
endElement
)
{
endElement
=
false
;
eventType
=
END_ELEMENT
;
currentToken
=
""
;
}
else
{
read
();
}
...
...
@@ -325,6 +328,10 @@ public class XMLParser {
return
currentText
;
}
public
String
getToken
()
{
return
currentToken
;
}
public
int
getAttributeCount
()
{
return
currentAttribute
/
3
;
}
...
...
h2/src/tools/org/h2/tools/i18n/PrepareTranslation.java
浏览文件 @
1556258b
...
...
@@ -8,12 +8,16 @@ 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.FileReader
;
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.Writer
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.Iterator
;
...
...
@@ -28,14 +32,15 @@ public class PrepareTranslation {
private
static
final
String
DELETED_PREFIX
=
"~"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
baseDir
=
"src/tools/org/h2/tools/i18n"
;
String
path
;
path
=
"src/main/org/h2/res"
;
prepare
(
baseDir
,
path
);
path
=
"src/main/org/h2/server/web/res"
;
prepare
(
baseDir
,
path
);
int
todoSwitchOn
;
// String baseDir = "src/tools/org/h2/tools/i18n";
// String path;
// path = "src/main/org/h2/res";
// prepare(baseDir, path);
// path = "src/main/org/h2/server/web/res";
// prepare(baseDir, path);
int
todoAllowTranslateHtmlFiles
;
//
extract("src/docsrc/html");
extract
(
"src/docsrc/html"
);
}
private
static
void
extract
(
String
dir
)
throws
Exception
{
...
...
@@ -65,28 +70,57 @@ public class PrepareTranslation {
return
false
;
}
private
static
void
extract
(
HashSet
set
,
String
documentName
,
File
f
)
throws
Exception
{
String
xml
=
IOUtils
.
readStringAndClose
(
new
FileReader
(
f
),
-
1
);
private
static
void
extract
(
HashSet
already
,
String
documentName
,
File
f
)
throws
Exception
{
String
xml
=
IOUtils
.
readStringAndClose
(
new
InputStreamReader
(
new
FileInputStream
(
f
),
"UTF-8"
),
-
1
);
// Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f.getName()), "UTF-8"));
XMLParser
parser
=
new
XMLParser
(
xml
);
StringBuffer
buff
=
new
StringBuffer
();
boolean
translate
=
true
;
String
tag
=
""
;
for
(
int
i
=
0
;;)
{
int
event
=
parser
.
next
();
String
s
=
parser
.
getToken
();
// writer.write(s);
if
(
event
==
XMLParser
.
END_DOCUMENT
)
{
break
;
}
else
if
(
event
==
XMLParser
.
CHARACTERS
)
{
String
text
=
parser
.
getText
().
trim
();
if
(
translate
&&
!
set
.
contains
(
text
)
&&
isText
(
text
))
{
System
.
out
.
println
(
documentName
+
"_"
+
i
++
);
System
.
out
.
println
(
text
);
System
.
out
.
println
();
set
.
add
(
text
);
String
text
=
parser
.
getText
();
if
(
translate
)
{
if
(
"p"
.
equals
(
tag
)
||
"li"
.
equals
(
tag
)
||
"a"
.
equals
(
tag
)
||
"td"
.
equals
(
tag
)
||
"th"
.
equals
(
tag
)
||
"h1"
.
equals
(
tag
)
||
"h2"
.
equals
(
tag
)
||
"h3"
.
equals
(
tag
)
||
"h4"
.
equals
(
tag
))
{
buff
.
append
(
text
);
}
else
if
(
text
.
trim
().
length
()
>
0
)
{
System
.
out
.
println
(
f
.
getName
()
+
" invalid wrapper tag for text: "
+
tag
+
" text: "
+
text
);
// System.out.println(parser.getRemaining());
}
}
}
else
if
(
event
==
XMLParser
.
START_ELEMENT
)
{
String
name
=
parser
.
getName
();
if
(
"
code"
.
equals
(
name
)
||
"pr
e"
.
equals
(
name
))
{
if
(
"
pre"
.
equals
(
name
)
||
"titl
e"
.
equals
(
name
))
{
translate
=
false
;
}
else
if
(
"p"
.
equals
(
name
)
||
"li"
.
equals
(
name
)
||
"a"
.
equals
(
name
)
||
"td"
.
equals
(
name
)
||
"th"
.
equals
(
name
)
||
"h1"
.
equals
(
name
)
||
"h2"
.
equals
(
name
)
||
"h3"
.
equals
(
name
)
||
"h4"
.
equals
(
name
))
{
translate
=
true
;
if
(
""
.
equals
(
tag
))
{
tag
=
name
;
}
}
else
if
(
translate
&&
(
"code"
.
equals
(
name
)
||
"a"
.
equals
(
name
)))
{
buff
.
append
(
parser
.
getToken
());
}
}
else
if
(
event
==
XMLParser
.
END_ELEMENT
)
{
String
name
=
parser
.
getName
();
if
(
"pre"
.
equals
(
name
))
{
translate
=
true
;
}
else
if
(
tag
.
equals
(
name
))
{
translate
=
false
;
tag
=
""
;
}
else
if
(
translate
)
{
if
(
"code"
.
equals
(
name
)
||
"a"
.
equals
(
name
))
{
buff
.
append
(
parser
.
getToken
());
}
}
translate
=
true
;
}
else
if
(
event
==
XMLParser
.
DTD
)
{
}
else
if
(
event
==
XMLParser
.
COMMENT
)
{
...
...
@@ -95,6 +129,7 @@ public class PrepareTranslation {
throw
new
Exception
(
"Unexpected event "
+
eventType
+
" at "
+
parser
.
getRemaining
());
}
}
// writer.close();
}
private
static
void
prepare
(
String
baseDir
,
String
path
)
throws
IOException
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论