Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
a74b366d
Commit
a74b366d
authored
4 years ago
by
Brad Payne (Vir Linden)
Browse files
Options
Downloads
Patches
Plain Diff
SL-13705 - single output file with one tab per translation language
parent
a1d24974
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/code_tools/modified_strings.py
+45
-34
45 additions, 34 deletions
scripts/code_tools/modified_strings.py
with
45 additions
and
34 deletions
scripts/code_tools/modified_strings.py
+
45
−
34
View file @
a74b366d
...
@@ -139,7 +139,7 @@ def should_translate(filename, elt, field, val):
...
@@ -139,7 +139,7 @@ def should_translate(filename, elt, field, val):
"""
"""
def
make_translation_
spreadsheet
(
mod_tree
,
base_tree
,
lang
,
args
):
def
make_translation_
table
(
mod_tree
,
base_tree
,
lang
,
args
):
xui_path
=
"
{}/{}
"
.
format
(
xui_base
,
args
.
base_lang
)
xui_path
=
"
{}/{}
"
.
format
(
xui_base
,
args
.
base_lang
)
try
:
try
:
...
@@ -195,7 +195,7 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
...
@@ -195,7 +195,7 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
new_val
=
"
(DUPLICATE)
"
new_val
=
"
(DUPLICATE)
"
else
:
else
:
new_val
=
""
new_val
=
""
data
.
append
([
val
,
transl_val
,
new_val
,
filename
,
name
,
field
])
data
.
append
([
val
,
transl_val
,
new_val
,
""
,
""
,
filename
,
name
,
field
])
all_en_strings
.
add
(
val
)
all_en_strings
.
add
(
val
)
rows
+=
1
rows
+=
1
for
attr
in
translate_attribs
:
for
attr
in
translate_attribs
:
...
@@ -215,48 +215,47 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
...
@@ -215,48 +215,47 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
else
:
else
:
new_val
=
""
new_val
=
""
#attr = attr + ":" + ET.tostring(elt)
#attr = attr + ":" + ET.tostring(elt)
data
.
append
([
val
,
transl_val
,
new_val
,
filename
,
name
,
attr
])
data
.
append
([
val
,
transl_val
,
new_val
,
""
,
""
,
filename
,
name
,
attr
])
all_en_strings
.
add
(
val
)
all_en_strings
.
add
(
val
)
rows
+=
1
rows
+=
1
return
data
save_
as_excel
(
data
,
lang
)
def
save_
translation_file
(
all_data
,
outfile
):
langs
=
sorted
(
all_data
.
keys
())
def
save_as_excel
(
data
,
lang
):
print
(
"
Saving languages
"
,
"
,
"
.
join
(
langs
),
"
as
"
,
outfile
)
outfile
=
"
SL_Translations_{}.xlsx
"
.
format
(
lang
.
upper
())
num_translations
=
len
(
data
)
cols
=
[
"
EN
"
,
"
Previous Translation ({})
"
.
format
(
lang
.
upper
()),
"
ENTER NEW TRANSLATION ({})
"
.
format
(
lang
.
upper
()),
"
File
"
,
"
Element
"
,
"
Field
"
]
df
=
pd
.
DataFrame
(
data
,
columns
=
cols
)
writer
=
pd
.
ExcelWriter
(
outfile
,
engine
=
'
xlsxwriter
'
)
writer
=
pd
.
ExcelWriter
(
outfile
,
engine
=
'
xlsxwriter
'
)
df
.
to_excel
(
writer
,
index
=
False
,
sheet_name
=
"
Sheet1
"
)
workbook
=
writer
.
book
workbook
=
writer
.
book
worksheet
=
writer
.
sheets
[
'
Sheet1
'
]
wrap_format
=
workbook
.
add_format
({
'
text_wrap
'
:
True
})
wrap_format
=
workbook
.
add_format
({
'
text_wrap
'
:
True
})
wrap_unlocked_format
=
workbook
.
add_format
({
'
text_wrap
'
:
True
,
'
locked
'
:
False
})
wrap_unlocked_format
=
workbook
.
add_format
({
'
text_wrap
'
:
True
,
'
locked
'
:
False
})
for
lang
in
langs
:
data
=
all_data
[
lang
]
num_translations
=
len
(
data
)
cols
=
[
"
EN
"
,
"
Previous Translation ({})
"
.
format
(
lang
.
upper
()),
"
ENTER NEW TRANSLATION ({})
"
.
format
(
lang
.
upper
()),
"
Translator Questions
"
,
"
Notes
"
,
"
File
"
,
"
Element
"
,
"
Field
"
]
df
=
pd
.
DataFrame
(
data
,
columns
=
cols
)
df
.
to_excel
(
writer
,
index
=
False
,
sheet_name
=
lang
.
upper
())
worksheet
=
writer
.
sheets
[
lang
.
upper
()]
# Translators primarily care about columns A-C, and should write
# Translators primarily care about columns A-C, and should write
# only in column C.
Can h
ide the others. Set widths.
# only in column C.
H
ide the others. Set widths.
worksheet
.
protect
()
worksheet
.
protect
()
worksheet
.
set_column
(
'
A:B
'
,
100
,
wrap_format
)
worksheet
.
set_column
(
'
A:B
'
,
60
,
wrap_format
)
worksheet
.
set_column
(
'
C:C
'
,
100
,
wrap_unlocked_format
)
worksheet
.
set_column
(
'
C:C
'
,
60
,
wrap_unlocked_format
)
worksheet
.
set_column
(
'
D:D
'
,
50
,
wrap_format
,
{
'
hidden
'
:
True
})
worksheet
.
set_column
(
'
D:E
'
,
40
,
wrap_unlocked_format
)
worksheet
.
set_column
(
'
E:F
'
,
30
,
wrap_format
,
{
'
hidden
'
:
True
})
worksheet
.
set_column
(
'
F:F
'
,
50
,
wrap_format
,
{
'
hidden
'
:
True
})
worksheet
.
set_column
(
'
G:H
'
,
30
,
wrap_format
,
{
'
hidden
'
:
True
})
# Lock the top row (column headers) in place while scrolling
# Lock the top row (column headers) in place while scrolling
worksheet
.
freeze_panes
(
1
,
0
)
worksheet
.
freeze_panes
(
1
,
0
)
print
(
"
Added
"
,
num_translations
,
"
rows for language
"
,
lang
)
print
(
"
Writing
"
,
outfile
)
writer
.
save
()
writer
.
save
()
if
num_translations
>
0
:
print
(
"
Wrote
"
,
num_translations
,
"
rows to file
"
,
outfile
)
else
:
print
(
"
Nothing to translate,
"
,
outfile
,
"
is empty
"
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
parser
=
argparse
.
ArgumentParser
(
description
=
"
analyze viewer xui files for needed translations
"
,
usage
=
usage_msg
)
parser
=
argparse
.
ArgumentParser
(
description
=
"
analyze viewer xui files for needed translations
"
,
usage
=
usage_msg
)
...
@@ -290,21 +289,33 @@ def save_as_excel(data, lang):
...
@@ -290,21 +289,33 @@ def save_as_excel(data, lang):
xui_base
=
"
indra/newview/skins/default/xui
"
xui_base
=
"
indra/newview/skins/default/xui
"
xui_base_tree
=
mod_tree
[
xui_base
]
xui_base_tree
=
mod_tree
[
xui_base
]
# Find target languages
valid_langs
=
[
tree
.
name
.
lower
()
for
tree
in
xui_base_tree
if
tree
.
name
.
lower
()
!=
args
.
base_lang
.
lower
()]
valid_langs
=
[
tree
.
name
.
lower
()
for
tree
in
xui_base_tree
if
tree
.
name
.
lower
()
!=
args
.
base_lang
.
lower
()]
langs
=
[
l
.
lower
()
for
l
in
args
.
lang
]
langs
=
[
l
.
lower
()
for
l
in
args
.
lang
]
if
"
all
"
in
args
.
lang
:
if
"
all
"
in
args
.
lang
:
langs
=
valid_langs
langs
=
valid_langs
langs
=
sorted
(
langs
)
for
lang
in
langs
:
for
lang
in
langs
:
if
not
lang
in
valid_langs
:
if
not
lang
in
valid_langs
:
failure
(
"
Unknown target language {}. Valid values are {} or all
"
.
format
(
lang
,
"
,
"
.
join
(
sorted
(
valid_langs
))))
failure
(
"
Unknown target language {}. Valid values are {} or all
"
.
format
(
lang
,
"
,
"
.
join
(
sorted
(
valid_langs
))))
print
(
"
Target language(s) are
"
,
"
,
"
.
join
(
sorted
(
langs
)))
print
(
"
Target language(s) are
"
,
"
,
"
.
join
(
sorted
(
langs
)))
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
outfile
=
"
SL_Translations.xlsx
"
try
:
f
=
open
(
outfile
,
"
a+
"
)
f
.
close
()
except
:
failure
(
"
Can
'
t write to output file
"
,
outfile
,
"
. Is it already open?
"
)
all_data
=
{}
for
lang
in
langs
:
for
lang
in
langs
:
print
(
"
Creating spreadsheet for language
"
,
lang
)
print
(
"
Creating spreadsheet for language
"
,
lang
)
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
make_translation_spreadsheet
(
mod_tree
,
base_tree
,
lang
,
args
)
all_data
[
lang
]
=
make_translation_table
(
mod_tree
,
base_tree
,
lang
,
args
)
print
(
"
Saving output file
"
,
outfile
)
save_translation_file
(
all_data
,
outfile
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment