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
713d896d
"README.md" did not exist on "1df1be10afd14fe80d491617e175f4586a78f71f"
Commit
713d896d
authored
4 years ago
by
Brad Payne (Vir Linden)
Browse files
Options
Downloads
Patches
Plain Diff
SL-13705 - added metadata tab to translation spreadsheet, showing invocation info
parent
a74b366d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/code_tools/modified_strings.py
+44
-26
44 additions, 26 deletions
scripts/code_tools/modified_strings.py
with
44 additions
and
26 deletions
scripts/code_tools/modified_strings.py
+
44
−
26
View file @
713d896d
...
@@ -34,6 +34,30 @@
...
@@ -34,6 +34,30 @@
from
git
import
Repo
,
Git
# requires the gitpython package
from
git
import
Repo
,
Git
# requires the gitpython package
import
pandas
as
pd
import
pandas
as
pd
import
re
import
re
from
datetime
import
datetime
usage_msg
=
"""
%(prog)s [options]
Analyze the XUI configuration files to find text that may need to
be translated. Works by comparing two specified revisions, one
specified by --rev (default HEAD) and one specified by --rev_base
(default master). The script works by comparing xui contents of the
two revisions, and outputs a spreadsheet listing any areas of
difference. The target language must be specified using the --lang
option. Output is an excel file, which can be used as-is or imported
into google sheets.
If the --rev revision already contains a translation for the text, it
will be included in the spreadsheet for reference.
Normally you would want --rev_base to be the last revision to have
translations added, and --rev to be the tip of the current
project. You can find the last commit with translation work using
"
git log --grep INTL- | head
"
The --missing argument can be used to find all text with missing
translations, regardless of when it was added. If translations are being kept
reasonably current, you will normally not need this argument.
"""
translate_attribs
=
[
translate_attribs
=
[
"
title
"
,
"
title
"
,
...
@@ -119,26 +143,6 @@ def should_translate(filename, elt, field, val):
...
@@ -119,26 +143,6 @@ def should_translate(filename, elt, field, val):
return
True
return
True
return
True
return
True
usage_msg
=
"""
%(prog)s [options]
Analyze the XUI configuration files to find text that may need to
be translated. Works by comparing two specified revisions, one
specified by --rev (default HEAD) and one specified by --rev_base
(default master). The script works by comparing xui contents of the
two revisions, and outputs a spreadsheet listing any areas of
difference. The target language must be specified using the --lang
option. Output is an excel file, which can be used as-is or imported
into google sheets.
If the --rev revision already contains a translation for the text, it
will be included in the spreadsheet for reference.
Normally you would want --rev_base to be the last revision to have
translations added, and --rev to be the tip of the current
project.
"""
def
make_translation_table
(
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
)
...
@@ -220,19 +224,20 @@ def make_translation_table(mod_tree, base_tree, lang, args):
...
@@ -220,19 +224,20 @@ def make_translation_table(mod_tree, base_tree, lang, args):
rows
+=
1
rows
+=
1
return
data
return
data
def
save_translation_file
(
all
_data
,
outfile
):
def
save_translation_file
(
per_lang_data
,
aux
_data
,
outfile
):
langs
=
sorted
(
all
_data
.
keys
())
langs
=
sorted
(
per_lang
_data
.
keys
())
print
(
"
Saving languages
"
,
"
,
"
.
join
(
langs
),
"
as
"
,
outfile
)
print
(
"
Saving languages
"
,
"
,
"
.
join
(
langs
),
"
as
"
,
outfile
)
writer
=
pd
.
ExcelWriter
(
outfile
,
engine
=
'
xlsxwriter
'
)
writer
=
pd
.
ExcelWriter
(
outfile
,
engine
=
'
xlsxwriter
'
)
workbook
=
writer
.
book
workbook
=
writer
.
book
wrap_format
=
workbook
.
add_format
({
'
text_wrap
'
:
True
})
wrap_format
=
workbook
.
add_format
({
'
text_wrap
'
:
True
})
bold_wrap_format
=
workbook
.
add_format
({
'
text_wrap
'
:
True
,
'
bold
'
:
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
:
for
lang
in
langs
:
data
=
all
_data
[
lang
]
data
=
per_lang
_data
[
lang
]
num_translations
=
len
(
data
)
num_translations
=
len
(
data
)
cols
=
[
"
EN
"
,
"
Previous Translation ({})
"
.
format
(
lang
.
upper
()),
"
ENTER NEW TRANSLATION ({})
"
.
format
(
lang
.
upper
()),
"
Translator Questions
"
,
"
Notes
"
,
"
File
"
,
"
Element
"
,
"
Field
"
]
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
=
pd
.
DataFrame
(
data
,
columns
=
cols
)
...
@@ -253,6 +258,14 @@ def save_translation_file(all_data, outfile):
...
@@ -253,6 +258,14 @@ def save_translation_file(all_data, outfile):
worksheet
.
freeze_panes
(
1
,
0
)
worksheet
.
freeze_panes
(
1
,
0
)
print
(
"
Added
"
,
num_translations
,
"
rows for language
"
,
lang
)
print
(
"
Added
"
,
num_translations
,
"
rows for language
"
,
lang
)
# Reference info, not for translation
for
aux
,
data
in
aux_data
.
items
():
df
=
pd
.
DataFrame
(
data
,
columns
=
[
"
Key
"
,
"
Value
"
])
df
.
to_excel
(
writer
,
index
=
False
,
sheet_name
=
aux
)
worksheet
=
writer
.
sheets
[
aux
]
worksheet
.
set_column
(
'
A:A
'
,
50
,
bold_wrap_format
)
worksheet
.
set_column
(
'
B:B
'
,
80
,
wrap_format
)
print
(
"
Writing
"
,
outfile
)
print
(
"
Writing
"
,
outfile
)
writer
.
save
()
writer
.
save
()
...
@@ -309,13 +322,18 @@ def save_translation_file(all_data, outfile):
...
@@ -309,13 +322,18 @@ def save_translation_file(all_data, outfile):
except
:
except
:
failure
(
"
Can
'
t write to output file
"
,
outfile
,
"
. Is it already open?
"
)
failure
(
"
Can
'
t write to output file
"
,
outfile
,
"
. Is it already open?
"
)
all_data
=
{}
aux_data
=
{
"
REFERENCE
"
:
[[
"
Command
"
,
"
"
.
join
(
sys
.
argv
)],
[
"
Date
"
,
str
(
datetime
.
now
())],
[
"
Mod Commit
"
,
mod_commit
.
hexsha
],
[
"
Base Commit
"
,
base_commit
.
hexsha
],
]
}
per_lang_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
()
all
_data
[
lang
]
=
make_translation_table
(
mod_tree
,
base_tree
,
lang
,
args
)
per_lang
_data
[
lang
]
=
make_translation_table
(
mod_tree
,
base_tree
,
lang
,
args
)
print
(
"
Saving output file
"
,
outfile
)
print
(
"
Saving output file
"
,
outfile
)
save_translation_file
(
all
_data
,
outfile
)
save_translation_file
(
per_lang_data
,
aux
_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