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
1eaa76f2
Commit
1eaa76f2
authored
4 years ago
by
Brad Payne (Vir Linden)
Browse files
Options
Downloads
Patches
Plain Diff
SL-13705 - quieter output
parent
3788fdbb
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
+35
-13
35 additions, 13 deletions
scripts/code_tools/modified_strings.py
with
35 additions
and
13 deletions
scripts/code_tools/modified_strings.py
+
35
−
13
View file @
1eaa76f2
...
@@ -76,13 +76,24 @@ def failure(*msg):
...
@@ -76,13 +76,24 @@ def failure(*msg):
print
(
*
msg
)
print
(
*
msg
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
def
should_translate
(
filename
,
val
):
# return True iff any element of lis is "in" thing
def
has_any
(
thing
,
lis
):
for
l
in
lis
:
if
l
in
thing
:
return
True
return
False
def
should_translate
(
filename
,
elt
,
field
,
val
):
if
val
is
None
:
if
val
is
None
:
return
False
return
False
if
"
floater_test
"
in
filename
:
# Should translate apply recursively?
if
"
translate
"
in
elt
.
attrib
and
elt
.
attrib
[
"
translate
"
]
==
"
false
"
:
return
False
if
has_any
(
filename
,[
"
floater_test
"
,
"
floater_aaa
"
,
"
floater_ui_preview
"
]):
return
False
return
False
if
"
TestString PleaseIgnore
"
in
val
:
if
"
TestString PleaseIgnore
"
in
val
:
return
False
return
False
val
=
re
.
sub
(
r
"
\[.*?\]
"
,
""
,
val
)
if
len
(
val
)
==
0
:
if
len
(
val
)
==
0
:
return
False
return
False
if
val
.
isspace
():
if
val
.
isspace
():
...
@@ -90,9 +101,22 @@ def should_translate(filename, val):
...
@@ -90,9 +101,22 @@ def should_translate(filename, val):
val
=
val
.
strip
()
val
=
val
.
strip
()
if
val
.
isdigit
():
if
val
.
isdigit
():
return
False
return
False
if
not
re
.
search
(
'
\w+
'
,
val
):
return
False
if
re
.
match
(
r
"
^\s*\d*\s*x\s*\d*\s*$
"
,
val
):
if
re
.
match
(
r
"
^\s*\d*\s*x\s*\d*\s*$
"
,
val
):
print
(
val
,
"
matches resolution string, will ignore
"
)
#
print(val, "matches resolution string, will ignore")
return
False
return
False
# "value" is a hairball, mostly used to encode non-display info but a few exceptions
if
field
==
"
value
"
:
if
elt
.
text
is
not
None
and
len
(
elt
.
text
)
>
0
:
#print("value has text, ignoring", ET.tostring(elt))
return
False
if
has_any
(
elt
.
attrib
,[
"
label
"
]):
return
False
if
elt
.
tag
in
[
"
string
"
,
"
text
"
]:
return
True
#print("including value attribute", val, "tag", elt.tag,"in", ET.tostring(elt))
return
True
return
True
return
True
usage_msg
=
"""
%(prog)s [options]
usage_msg
=
"""
%(prog)s [options]
...
@@ -150,7 +174,7 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
...
@@ -150,7 +174,7 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
transl_blob
=
mod_tree
[
transl_filename
]
transl_blob
=
mod_tree
[
transl_filename
]
except
:
except
:
if
args
.
verbose
:
if
args
.
verbose
:
failure
(
"
No matching translation file found at
"
,
transl_filename
)
print
(
"
No matching translation file found at
"
,
transl_filename
)
transl_blob
=
None
transl_blob
=
None
mod_dict
=
read_xml_elements
(
mod_blob
)
mod_dict
=
read_xml_elements
(
mod_blob
)
...
@@ -160,8 +184,10 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
...
@@ -160,8 +184,10 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
rows
=
0
rows
=
0
for
name
in
mod_dict
.
keys
():
for
name
in
mod_dict
.
keys
():
if
not
name
in
base_dict
or
mod_dict
[
name
].
text
!=
base_dict
[
name
].
text
or
(
args
.
missing
and
not
name
in
transl_dict
):
if
not
name
in
base_dict
or
mod_dict
[
name
].
text
!=
base_dict
[
name
].
text
or
(
args
.
missing
and
not
name
in
transl_dict
):
val
=
mod_dict
[
name
].
text
elt
=
mod_dict
[
name
]
if
should_translate
(
filename
,
val
):
val
=
elt
.
text
field
=
"
text
"
if
should_translate
(
filename
,
elt
,
field
,
val
):
transl_val
=
"
--
"
transl_val
=
"
--
"
if
name
in
transl_dict
:
if
name
in
transl_dict
:
transl_val
=
transl_dict
[
name
].
text
transl_val
=
transl_dict
[
name
].
text
...
@@ -169,7 +195,6 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
...
@@ -169,7 +195,6 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
new_val
=
"
(DUPLICATE)
"
new_val
=
"
(DUPLICATE)
"
else
:
else
:
new_val
=
""
new_val
=
""
field
=
"
text
"
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
...
@@ -181,10 +206,7 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
...
@@ -181,10 +206,7 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
or
(
args
.
missing
and
(
not
name
in
transl_dict
or
not
attr
in
transl_dict
[
name
].
attrib
)):
or
(
args
.
missing
and
(
not
name
in
transl_dict
or
not
attr
in
transl_dict
[
name
].
attrib
)):
elt
=
mod_dict
[
name
]
elt
=
mod_dict
[
name
]
val
=
elt
.
attrib
[
attr
]
val
=
elt
.
attrib
[
attr
]
#if attr == "value" and elt.tag not in ["string","text"]:
if
should_translate
(
filename
,
elt
,
attr
,
val
):
# print("skipping value attribute", val, "tag", elt.tag, "in", filename)
# continue
if
should_translate
(
filename
,
val
):
transl_val
=
"
--
"
transl_val
=
"
--
"
if
name
in
transl_dict
and
attr
in
transl_dict
[
name
].
attrib
:
if
name
in
transl_dict
and
attr
in
transl_dict
[
name
].
attrib
:
transl_val
=
transl_dict
[
name
].
attrib
[
attr
]
transl_val
=
transl_dict
[
name
].
attrib
[
attr
]
...
@@ -192,8 +214,8 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
...
@@ -192,8 +214,8 @@ def make_translation_spreadsheet(mod_tree, base_tree, lang, args):
new_val
=
"
(DUPLICATE)
"
new_val
=
"
(DUPLICATE)
"
else
:
else
:
new_val
=
""
new_val
=
""
field
=
attr
#attr
= attr
+ ":" + ET.tostring(elt)
data
.
append
([
val
,
transl_val
,
new_val
,
filename
,
name
,
field
])
data
.
append
([
val
,
transl_val
,
new_val
,
filename
,
name
,
attr
])
all_en_strings
.
add
(
val
)
all_en_strings
.
add
(
val
)
rows
+=
1
rows
+=
1
if
args
.
verbose
and
rows
>
0
:
if
args
.
verbose
and
rows
>
0
:
...
...
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