Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
37378abe
Commit
37378abe
authored
Jan 19, 2011
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Language translationfiles, include statement added
parent
acbcc7f0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
155 additions
and
78 deletions
+155
-78
src/lib/co/src/co_lng.cpp
src/lib/co/src/co_lng.cpp
+147
-74
src/lib/co/src/co_lng.h
src/lib/co/src/co_lng.h
+3
-1
src/msg/co/src/co_lng_msg.msg
src/msg/co/src/co_lng_msg.msg
+5
-3
No files found.
src/lib/co/src/co_lng.cpp
View file @
37378abe
...
...
@@ -345,7 +345,6 @@ bool Lng::read()
{
char
fname1
[
120
];
char
fname2
[
120
];
pwr_tFileName
filename1
,
filename2
;
pwr_tStatus
sts
;
if
(
tree
)
...
...
@@ -354,82 +353,106 @@ bool Lng::read()
tree
=
tree_CreateTable
(
&
sts
,
sizeof
(
lang_sKey
),
offsetof
(
lang_sRecord
,
key
),
sizeof
(
lang_sRecord
),
100
,
compKey
);
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
if
(
i
==
0
)
{
strcpy
(
fname1
,
"$pwr_exe/en_us/xtt_lng.dat"
);
strcpy
(
fname2
,
"$pwr_exe/%s/xtt_lng.dat"
);
}
else
{
strcpy
(
fname1
,
"$pwrp_exe/xtt_lng_en_us.dat"
);
strcpy
(
fname2
,
"$pwrp_exe/xtt_lng_%s.dat"
);
}
sprintf
(
filename2
,
fname2
,
get_language_str
());
dcli_translate_filename
(
filename1
,
fname1
);
dcli_translate_filename
(
filename2
,
filename2
);
// Read base files
strcpy
(
fname1
,
"$pwr_exe/en_us/xtt_lng.dat"
);
strcpy
(
fname2
,
"$pwr_exe/%s/xtt_lng.dat"
);
ifstream
fp1
(
filename1
);
if
(
!
fp1
&&
i
==
0
)
{
// Try $pwr_eexe
strcpy
(
fname1
,
"$pwr_eexe/en_us/xtt_lng.dat"
);
dcli_translate_filename
(
filename1
,
fname1
);
fp1
.
open
(
filename1
);
if
(
!
fp1
)
return
true
;
}
else
if
(
!
fp1
)
return
i
==
0
?
false
:
true
;
ifstream
fp2
(
filename2
);
if
(
!
fp2
&&
i
==
0
)
{
// Try $pwr_eexe
strcpy
(
fname2
,
"$pwr_eexe/%s/xtt_lng.dat"
);
sprintf
(
filename2
,
fname2
,
get_language_str
());
dcli_translate_filename
(
filename2
,
filename2
);
fp2
.
open
(
filename2
);
if
(
!
fp2
)
return
true
;
}
else
if
(
!
fp2
)
return
i
==
0
?
false
:
true
;
if
(
!
read_files
(
fname1
,
fname2
,
true
,
&
sts
))
return
false
;
Row
r1
(
fp1
,
fname1
);
Row
r2
(
fp2
,
fname2
);
// Read project files
strcpy
(
fname1
,
"$pwrp_exe/xtt_lng_en_us.dat"
);
strcpy
(
fname2
,
"$pwrp_exe/xtt_lng_%s.dat"
);
read_metadata
(
fp2
,
(
i
==
0
),
&
sts
);
if
(
!
read_files
(
fname1
,
fname2
,
false
,
&
sts
))
return
false
;
bool
hit
=
true
;
for
(;;)
{
if
(
hit
)
{
if
(
!
read_line
(
r1
))
break
;
return
true
;
}
if
(
!
read_line
(
r2
))
break
;
}
else
if
(
r1
.
lt
(
r2
))
{
if
(
!
read_line
(
r1
))
break
;
}
else
{
if
(
!
read_line
(
r2
))
break
;
}
bool
Lng
::
read_files
(
char
*
fname1
,
char
*
fname2
,
bool
global
,
pwr_tStatus
*
sts
)
{
pwr_tFileName
filename1
,
filename2
;
hit
=
false
;
if
(
r1
.
eq
(
r2
))
hit
=
true
;
if
(
hit
)
{
lang_sKey
key
;
lang_sRecord
*
record
;
strncpy
(
key
.
text
,
r1
.
text
,
sizeof
(
key
.
text
));
key
.
type
=
r1
.
type
;
record
=
(
lang_sRecord
*
)
tree_Insert
(
&
sts
,
tree
,
&
key
);
strcpy
(
record
->
transl
,
r2
.
text
);
// printf ( "%c %d.%d.%d '%s' '%s'\n", r1.type, r1.n1, r1.n2, r1.n3, r1.text,r2.text);
}
}
sprintf
(
filename2
,
fname2
,
get_language_str
());
dcli_translate_filename
(
filename1
,
fname1
);
dcli_translate_filename
(
filename2
,
filename2
);
ifstream
fp1
(
filename1
);
if
(
!
fp1
&&
strcmp
(
fname1
,
"$pwr_exe/en_us/xtt_lng.dat"
)
==
0
)
{
// Try $pwr_eexe
strcpy
(
fname1
,
"$pwr_eexe/en_us/xtt_lng.dat"
);
dcli_translate_filename
(
filename1
,
fname1
);
fp1
.
open
(
filename1
);
if
(
!
fp1
)
{
*
sts
=
LNG__FILE
;
return
false
;
}
}
else
if
(
!
fp1
)
{
*
sts
=
LNG__FILE
;
return
global
?
false
:
true
;
}
ifstream
fp2
(
filename2
);
if
(
!
fp2
&&
strcmp
(
fname2
,
"$pwr_exe/%s/xtt_lng.dat"
)
==
0
)
{
// Try $pwr_eexe
strcpy
(
fname2
,
"$pwr_eexe/%s/xtt_lng.dat"
);
sprintf
(
filename2
,
fname2
,
get_language_str
());
dcli_translate_filename
(
filename2
,
filename2
);
fp2
.
open
(
filename2
);
if
(
!
fp2
)
{
*
sts
=
LNG__FILE
;
return
false
;
}
}
else
if
(
!
fp2
)
{
*
sts
=
LNG__FILE
;
return
global
?
false
:
true
;
}
Row
r1
(
fp1
,
filename1
);
Row
r2
(
fp2
,
filename2
);
read_metadata
(
fp1
,
global
,
sts
);
read_metadata
(
fp2
,
global
,
sts
);
read_include
(
fp1
,
fp2
,
global
,
sts
);
bool
hit
=
true
;
for
(;;)
{
if
(
hit
)
{
if
(
!
read_line
(
r1
))
break
;
if
(
!
read_line
(
r2
))
break
;
}
else
if
(
r1
.
lt
(
r2
))
{
if
(
!
read_line
(
r1
))
break
;
}
else
{
if
(
!
read_line
(
r2
))
break
;
}
hit
=
false
;
if
(
r1
.
eq
(
r2
))
hit
=
true
;
if
(
hit
)
{
lang_sKey
key
;
lang_sRecord
*
record
;
strncpy
(
key
.
text
,
r1
.
text
,
sizeof
(
key
.
text
));
key
.
type
=
r1
.
type
;
record
=
(
lang_sRecord
*
)
tree_Insert
(
sts
,
tree
,
&
key
);
strcpy
(
record
->
transl
,
r2
.
text
);
// printf ( "%c %d.%d.%d '%s' '%s'\n", r1.type, r1.n1, r1.n2, r1.n3, r1.text,r2.text);
}
}
*
sts
=
LNG__SUCCESS
;
return
true
;
}
...
...
@@ -575,11 +598,14 @@ void Lng::read_metadata( ifstream& fp2, bool global, pwr_tStatus *sts)
{
char
line
[
40
];
if
(
!
fp2
.
getline
(
line
,
sizeof
(
line
)))
{
*
sts
=
LNG__EOF
;
return
;
for
(;;)
{
if
(
!
fp2
.
getline
(
line
,
sizeof
(
line
)))
{
*
sts
=
LNG__EOF
;
return
;
}
if
(
line
[
0
]
!=
'#'
)
break
;
}
*
sts
=
LNG__SUCCESS
;
if
(
strncmp
(
line
,
"Coding:UTF-8"
,
12
)
==
0
)
{
if
(
global
)
...
...
@@ -600,6 +626,53 @@ void Lng::read_metadata( ifstream& fp2, bool global, pwr_tStatus *sts)
else
if
(
translfile_coding
!=
lng_eCoding_ISO8859_1
)
*
sts
=
LNG__DIFFCODING
;
}
*
sts
=
LNG__SUCCESS
;
}
void
Lng
::
read_include
(
ifstream
&
fp1
,
ifstream
&
fp2
,
bool
global
,
pwr_tStatus
*
sts
)
{
char
line1
[
200
];
char
line2
[
200
];
streampos
pos1
;
pwr_tFileName
fname1
,
fname2
;
for
(;;)
{
pos1
=
fp1
.
tellg
();
for
(;;)
{
if
(
!
fp1
.
getline
(
line1
,
sizeof
(
line1
)))
{
*
sts
=
LNG__EOF
;
return
;
}
if
(
line1
[
0
]
!=
'#'
)
break
;
}
if
(
strncmp
(
line1
,
"Include:"
,
8
)
==
0
)
{
for
(;;)
{
if
(
!
fp2
.
getline
(
line2
,
sizeof
(
line2
)))
{
*
sts
=
LNG__EOF
;
return
;
}
if
(
line2
[
0
]
!=
'#'
)
break
;
}
if
(
strncmp
(
line2
,
"Include:"
,
8
)
!=
0
)
{
*
sts
=
LNG__INCLUDEMISMATCH
;
return
;
}
dcli_trim
(
fname1
,
&
line1
[
8
]);
dcli_trim
(
fname2
,
&
line2
[
8
]);
if
(
!
read_files
(
fname1
,
fname2
,
global
,
sts
))
return
;
}
else
{
fp1
.
seekg
(
pos1
);
break
;
}
}
*
sts
=
LNG__SUCCESS
;
}
...
...
src/lib/co/src/co_lng.h
View file @
37378abe
...
...
@@ -207,7 +207,7 @@ class Row {
char
fname
[
200
];
Row
(
ifstream
&
f
,
char
*
filename
)
:
row
(
0
),
fp
(
f
)
{
strcpy
(
text
,
""
);
str
cpy
(
fname
,
filename
);}
strcpy
(
text
,
""
);
str
ncpy
(
fname
,
filename
,
sizeof
(
fname
)
);}
bool
eq
(
Row
&
r
)
{
return
n1
==
r
.
n1
&&
n2
==
r
.
n2
&&
n3
==
r
.
n3
;}
bool
lt
(
Row
&
r
)
{
if
(
n1
<
r
.
n1
)
...
...
@@ -261,6 +261,7 @@ class Lng {
static
tree_sTable
*
tree
;
static
bool
read
();
static
bool
read_files
(
char
*
fname1
,
char
*
fname2
,
bool
global
,
pwr_tStatus
*
sts
);
static
bool
read_line
(
Row
&
r
);
static
char
*
translate
(
const
char
*
text
);
static
char
*
get_language_str
();
...
...
@@ -279,6 +280,7 @@ class Lng {
static
char
*
lang_to_locale
(
lng_eLanguage
language
);
static
bool
is_installed
(
lng_eLanguage
language
);
static
lng_eCoding
translatefile_coding
()
{
return
translfile_coding
;}
static
void
read_include
(
ifstream
&
fp1
,
ifstream
&
fp2
,
bool
global
,
pwr_tStatus
*
sts
);
static
void
read_metadata
(
ifstream
&
fp2
,
bool
global
,
pwr_tStatus
*
sts
);
};
...
...
src/msg/co/src/co_lng_msg.msg
View file @
37378abe
...
...
@@ -22,8 +22,10 @@
!
.facility LNG,108 /prefix = LNG__ ! System information
success <successful completion> /succ
eof <end of file> /error
diffcoding <coding of global and local translationfiles differ> /error
success <Successful completion> /succ
eof <End of file> /error
diffcoding <Coding of global and local translationfiles differ> /error
file <Unable to open file> /error
includemismatch <Include statement mismatch> /error
.end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment