Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
XDG Integration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
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
JennaHuntsman
XDG Integration
Commits
cef702d0
Commit
cef702d0
authored
4 years ago
by
Brad Payne (Vir Linden)
Browse files
Options
Downloads
Patches
Plain Diff
SL-13705 - bug fixes and comments
parent
f28437ad
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
-16
44 additions, 16 deletions
scripts/code_tools/modified_strings.py
with
44 additions
and
16 deletions
scripts/code_tools/modified_strings.py
+
44
−
16
View file @
cef702d0
#!/usr/bin/env python
"""
\
This
module contains tools for
scan
ning
the SL codebase for translation-related strings.
This
script
scan
s
the SL codebase for translation-related strings.
$LicenseInfo:firstyear=2020&license=viewerlgpl$
Second Life Viewer Source Code
...
...
@@ -26,8 +27,6 @@
from
__future__
import
print_function
# packages required include: gitpython, pandas
import
xml.etree.ElementTree
as
ET
import
argparse
import
os
...
...
@@ -61,6 +60,8 @@ def read_xml_elements(blob):
try
:
contents
=
blob
.
data_stream
.
read
()
except
:
# default - pretend we read a file with no elements of interest.
# Parser will complain if it gets no elements at all.
contents
=
'
<?xml version=
"
1.0
"
encoding=
"
utf-8
"
standalone=
"
yes
"
?><strings></strings>
'
xml
=
ET
.
fromstring
(
contents
)
elts
=
{}
...
...
@@ -83,23 +84,37 @@ def can_translate(val):
if
val
.
isdigit
():
return
False
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.
"""
if
__name__
==
"
__main__
"
:
parser
=
argparse
.
ArgumentParser
(
description
=
"
analyze viewer xui files
"
)
parser
=
argparse
.
ArgumentParser
(
description
=
"
analyze viewer xui files
for needed translations
"
,
usage
=
usage_msg
)
parser
.
add_argument
(
"
-v
"
,
"
--verbose
"
,
action
=
"
store_true
"
,
help
=
"
verbose flag
"
)
parser
.
add_argument
(
"
--rev
"
,
help
=
"
revision with modified strings, default HEAD
"
,
default
=
"
HEAD
"
)
parser
.
add_argument
(
"
--rev_base
"
,
help
=
"
previous revision to compare against, default master
"
,
default
=
"
master
"
)
parser
.
add_argument
(
"
--base_lang
"
,
help
=
"
base language, default en (useful only for testing)
"
,
default
=
"
en
"
)
parser
.
add_argument
(
"
--lang
"
,
help
=
"
target language
, default fr
"
,
default
=
"
fr
"
)
parser
.
add_argument
(
"
--lang
"
,
help
=
"
target language
"
)
args
=
parser
.
parse_args
()
if
args
.
rev
==
args
.
rev_base
:
failure
(
"
Revs are the same, nothing to compare
"
)
print
(
"
Finding changes in
"
,
args
.
rev
,
"
not present in
"
,
args
.
rev_base
)
sys
.
stdout
.
flush
()
cwd
=
os
.
getcwd
()
rootdir
=
Git
(
cwd
).
rev_parse
(
"
--show-toplevel
"
)
repo
=
Repo
(
rootdir
)
...
...
@@ -115,11 +130,23 @@ def can_translate(val):
mod_tree
=
mod_commit
.
tree
base_tree
=
base_commit
.
tree
xui_path
=
"
indra/newview/skins/default/xui/{}
"
.
format
(
args
.
base_lang
)
xui_base
=
"
indra/newview/skins/default/xui
"
xui_base_tree
=
mod_tree
[
xui_base
]
valid_langs
=
[
tree
.
name
.
lower
()
for
tree
in
xui_base_tree
if
tree
.
name
.
lower
()
!=
args
.
base_lang
.
lower
()]
if
not
args
.
lang
or
not
args
.
lang
.
lower
()
in
valid_langs
:
failure
(
"
Please specify a target language using --lang. Valid values are
"
,
"
,
"
.
join
(
sorted
(
valid_langs
)))
xui_path
=
"
{}/{}
"
.
format
(
xui_base
,
args
.
base_lang
)
try
:
mod_xui_tree
=
mod_tree
[
xui_path
]
except
:
failure
(
"
xui tree not found for language
"
,
args
.
base_lang
)
failure
(
"
xui tree not found for base language
"
,
args
.
base_lang
)
if
args
.
rev
==
args
.
rev_base
:
failure
(
"
Revs are the same, nothing to compare
"
)
print
(
"
Finding changes in
"
,
args
.
rev
,
"
not present in
"
,
args
.
rev_base
)
sys
.
stdout
.
flush
()
data
=
[]
# For all files to be checked for translations
...
...
@@ -130,6 +157,7 @@ def can_translate(val):
if
args
.
verbose
:
print
(
filename
)
try
:
base_blob
=
base_tree
[
filename
]
except
:
...
...
@@ -138,11 +166,11 @@ def can_translate(val):
base_blob
=
None
try
:
transl_filename
=
filename
.
replace
(
args
.
base_lang
,
args
.
lang
)
transl_filename
=
filename
.
replace
(
"
/xui/{}/
"
.
format
(
args
.
base_lang
)
,
"
/xui/{}/
"
.
format
(
args
.
lang
)
)
transl_blob
=
mod_tree
[
transl_filename
]
except
:
if
args
.
verbose
:
print
(
"
No matching translation file found at
"
,
transl_filename
)
failure
(
"
No matching translation file found at
"
,
transl_filename
)
transl_blob
=
None
mod_dict
=
read_xml_elements
(
mod_blob
)
...
...
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