Skip to content

Commit

Permalink
Allow a wild card at any position in laguage strings. deduplictaed th…
Browse files Browse the repository at this point in the history
…e code.
  • Loading branch information
daschuer committed Nov 2, 2024
1 parent 0dee602 commit 233777b
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 99 deletions.
113 changes: 55 additions & 58 deletions res/translations/source_copy_allow_list.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ lang source
* RGB L/R
* RGB Stacked
* VSyncTest
ca,cs,de,el,en_CA,en_GB,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,et,fr,fr_CA,fr_CI,hu,it,nl,pl,pt,pt_BR,pt_PT,ro,ru,sl,sv,tr,vi,zh,zh_CN,zh_HK,zh_TW Rot64
ca,cs,de,el,en_CA,en_GB,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,et,fr,fr_CA,fr_CI,hu,it,nl,pl,pt,pt_BR,pt_PT,ru,sl,sv,vi,zh,zh_CN,zh_HK,zh_TW Rot64Inv
ca,cs,de,el,en_CA,en_GB,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,et,fr,fr_CA,fr_CI,hu,it,nl,pl,pt,pt_BR,pt_PT,ru,sl,sv,vi,zh,zh_CN,zh_HK,zh_TW Rot64Fast
ca,de,el,en_CA,en_GB,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,fr,fr_CA,fr_CI,hu,it,nl,pl,pt,pt_BR,pt_PT,ro,sl,sv,zh,zh_CN,zh_HK Diff
ca,cs,de,el,en_CA,en_GB,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,fr,fr_CA,fr_CI,hu,it,nl,pl,pt,pt_BR,pt_PT,ro,ru,sl,sv,tr,vi,zh,zh_CN,zh_HK,zh_TW Spread64
ca,cs,de,el,en_CA,en_GB,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,fr,fr_CA,fr_CI,hu,it,nl,pl,pt,pt_BR,pt_PT,ro,ru,sl,sv,vi,zh,zh_CN,zh_HK,zh_TW HercJog
ca,cs,de,el,en_CA,en_GB,fr,fr_CA,fr_CI,hu,it,pl,pt_BR,ru,sl,sv,vi,zh,zh_HK,zh_TW SelectKnob
* Rot64
* Rot64Inv
* Rot64Fast
* Diff
* Spread64
* HercJog
* SelectKnob
* 14-bit (LSB)
* 14-bit (MSB)
* Bitcrusher
Expand All @@ -140,7 +140,7 @@ ca,cs,de,el,en_CA,en_GB,fr,fr_CA,fr_CI,hu,it,pl,pt_BR,ru,sl,sv,vi,zh,zh_HK,zh_TW
* Mix
* Autopan
* Bessel4 ISO
ca,de,el,en_CA,en_GB,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,fr_CA,fr_CI,hu,it,nl,pt,pt_BR,pt_PT,sl,sv Res
ca,de,el,en_CA,en_GB,es*,fr_CA,fr_CI,hu,it,nl,pt*,sl,sv Res
* %1:%2
* Bessel8 ISO
* LR8 ISO
Expand Down Expand Up @@ -173,31 +173,31 @@ de,da,fr,lb,ms,nl,oc,sv Genre
de,it,pl Bitrate:
es,es_419,es_AR,es_CO,es_MX,ca,es_ES Error:
pt_BR,de,el,es_419,es_AR,es_CO,es_CR,es_EC,es_MX,es_PA,es_UY,id,it,nl,ro Deck %1
hu,da,de,el,es_419,es_AR,es_CO,es_CR,es_EC,es_MX,es_PA,es_UY,eu,id,nb,nl,pl,pt,pt_BR,pt_PT,ro,sn,tr,vi Sampler %1
hu,da,de,el,es_419,es_AR,es_CO,es_CR,es_EC,es_MX,es_PA,es_UY,eu,id,nb,nl,pl,pt*,ro,sn,tr,vi Sampler %1
hu,id,nl,sn Auxiliary %1
* Crossfader
* Cue
hu,ca,de,et,fr,nb,pl,ro,sv,tr Port
hu,cs,de,et,fi,fr,nl,pl,pt_BR,ro,ru,sl,vi,zh,zh_CN,zh_HK,zh_T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ru,sl,vi,zh* G
hu,et,fi,nl,pl,pt_BR,ro,sl,zh* Ab
hu,et,fi,nl,pl,pt_BR,ro,sl,zh,zh_CN,zh_HK Am
hu,et,fi,nl,pl,pt_BR,ro,zh,zh_CN,zh_HK,zh_TW Bbm
hu,et,fi,nl,pl,pt_BR,ro,zh,zh_CN,zh_HK,zh_TW Bm
hu,et,fi,nl,pl,pt_BR,ro,zh* Bbm
hu,et,fi,nl,pl,pt_BR,ro,zh* Bm
hu,et,fi,nl,pl,pt_BR,ro,sl,vi,zh,zh_CN,zh_HK Cm
hu,et,fi,nl,pl,pt_BR,ro,sl,zh_CN C#m
hu,et,fi,nl,pl,pt_BR,ro,sl,zh,zh_CN,zh_HK,zh_TW Dm
hu,et,fi,nl,pl,pt_BR,ro,sl,zh* Dm
hu,et,fi,nl,pl,pt_BR,ro,sl,zh,zh_CN,zh_HK Ebm
hu,de,et,fi,nl,pl,pt_BR,ro,sl,vi,zh,zh_CN,zh_HK,zh_TW Em
hu,de,et,fi,nl,pl,pt_BR,ro,sl,vi,zh* Em
hu,et,fi,nl,pl,pt_BR,ro,sl,zh_CN Fm
hu,et,fi,nl,pl,pt_BR,ro,sl,zh,zh_CN,zh_HK F#m
hu,et,fi,nl,pl,pt_BR,ro,sl,zh,zh_CN,zh_HK Gm
Expand All @@ -213,18 +213,16 @@ hu,bs,de,eu,fr,hr,it,lb,nl,ro,sk,sv,vi Max
pt,pt_BR,ca,de,fr,it,nl,pl,pt_PT,sl,sv Tremolo
pt_BR,da,de,id,it,nl,pt,ro Mixer
pt_BR,de,it,nl,pt_PT Reloop
de,es,es_419,es_AR,es_CO,es_ES,es_MX,nl,pt_BR,vi Hotcues
de,es*,nl,pt_BR,vi Hotcues
de,es_CR,es_EC,es_PA,es_UY,it,nl,pt_BR,pt_PT,vi,pl Hotcues %1-%2
nl,pl Hotcue index
de,it,nl,pl Hotcue #%1
fr,de,sv Information
fr,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY Simple
ca,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY Color
fr,es* Simple
ca,es* Color
nl is
nl Cover
nl Track BPM:
nl Artist + Title
nl Artist + Album
nl MIDI Controller
nl Help
nl Later
Expand Down Expand Up @@ -252,8 +250,6 @@ sv Full
sv Period
vi Shuffle
vi Relink
nl Lossy
nl Lossless
nl Vinyl Type
nl,sl OpenGL status
nl Waveforms
Expand All @@ -262,7 +258,7 @@ nl Modplug Decoder
nl,sv Center 1
nl Label...
sn Super Knob
ca,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,gl,ro Control
ca,es*,gl,ro Control
it Jog Wheel / Select Knob
ca,it Jog Wheel / Select Knob
nl Volume Fader
Expand Down Expand Up @@ -296,19 +292,19 @@ nl,pt_BR,pt_PT Item
ca Controls
ca,de,fr,nb,oc,pl,ro,sl,sv Format
ca,fr,nl,ro,sv Permanent
ca,de,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,fr,gl,pt,pt_BR,pt_PT,ro,sv,tr Global
ca,de,es*,fr,gl,pt*,ro,sv,tr Global
ca Colors
ca,de,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,it,pl,pt,pt_BR,pt_PT,sv Pitch Bend
ca,de,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,fr,pl,pt,pt_BR,pt_PT,ro,sv,tr Normal
ca,de,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,fr,it,nl,pl,pt,pt_BR,pt_PT,ro,sv Script
ca,de,es*,it,pl,pt*,sv Pitch Bend
ca,de,es*,fr,pl,pt*,ro,sv,tr Normal
ca,de,es*,fr,it,nl,pl,pt*,ro,sv Script
ca,nl Moog Ladder 4 Filter
ca,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY Mid/Side
ca,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,fr,sl Triplet
ca,cs,de,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,et,fi,fr,gl,it,nl,pt,pt_BR,pt_PT,sl,sv,tr Tempo
ca,cs,de,es,es_419,es_AR,es_CO,es_CR,es_EC,es_ES,es_MX,es_PA,es_UY,fr,it,nl,pt,pt_BR,pt_PT,ro,sl,sv,tr,vi,zh_CN MESA vblank_mode = 1
ca,es* Mid/Side
ca,es*,fr,sl Triplet
ca,cs,de,es*,et,fi,fr,gl,it,nl,pt*,sl,sv,tr Tempo
* MESA vblank_mode = 1
ca,de,fr,it,nl,pl,sv Intro
cs,de,fr,sl Formant
da,es,es_ES,eu,fr,hu,id,it,lv,nb,oc,pl,pt,pt_BR,pt_PT,ro,ru,sk,sv Auto DJ
da,es,es_ES,eu,fr,hu,id,it,lv,nb,oc,pl,pt*,ro,ru,sk,sv Auto DJ
da,fr,nb,nl,nn Type
de,nl,pl,sv Status
da,de,it,nl Computer
Expand All @@ -319,7 +315,7 @@ da,nl Platform:
fr Description
fr Microphone %1
it,sn Slot %1
fr,gl,it,nl,pt,pt_BR,pt_PT Volume
fr,gl,it,nl,pt* Volume
fr Orientation
fr Gain
fr Options
Expand All @@ -328,14 +324,14 @@ fr,nl,ro sec.
fr Compression
fr,nl Type (#)
fr Placement
fr,gl,pt,pt_BR,pt_PT Interface
fr,gl,pt* Interface
fr Question
fr Microphone
fr %1 minutes
fr,it Bypass Fr.
fr Gain 1
fr Gain 2
fr,it,ru Queen Mary University London
fr,it,ru,es* Queen Mary University London
fr,nl Distortion
fr Ratio (:1)
fr Ratio
Expand All @@ -353,7 +349,7 @@ it,nl,pt_BR Log
it,nl,pl,pt_BR,pt_PT Login
it Fine
it Deck Equalizers
it,nl Lead-In
it,nl,es* Lead-In
it Frame rate
it,nl,pt_BR Caching
it,nl skin
Expand All @@ -362,10 +358,10 @@ de Timer (Fallback)
de,fr,it,nl,pl,sv Outro
de,nl Loops
el,pt_BR Tool tips
el,es,es_419,es_AR,es_CO,es_ES,es_MX,eu,id,it,lb,nb,pt,pt_BR,pt_PT,tr Scratching
es,es_419,es_AR,es_CO,es_ES,es_MX,fr,it,nl,pt,pt_BR,pt_PT &Ok
es,es_419,es_AR,es_CO,es_ES,es_MX,pt_BR Switch
es,es_419,es_AR,es_CO,es_ES,es_MX,pt,pt_BR,pt_PT Manual
el,es*,eu,id,it,lb,nb,pt*,tr Scratching
es*,fr,it,nl,pt* &Ok
es*,pt_BR Switch
es*,pt* Manual
et,hr,it,tr,vi BPM Tap
fr pt
it Password
Expand All @@ -378,18 +374,18 @@ nl Hard
sv (status text)
da Input
de,nl Moog Filter
de,fr,it,nl,pt,pt_BR,pt_PT,ro,sv Phaser
de,fr,it,nl,pt*,ro,sv Phaser
de,it,nl,pt_PT,ru Bessel4 LV-Mix Isolator
de,it,nl,pt_PT,ru,sv Bessel8 LV-Mix Isolator
de,nl,pt,pt_PT,ru,sv LinkwitzRiley8 Isolator
de,es,es_419,es_AR,es_CO,es_ES,es_MX,fr,gl Balance
de,es*,fr,gl Balance
de,fr Phase
de,it,nl Drive
de,it,nl,es* Drive
de,fr,it,pl Passthrough
de,it,nl Glitch
de Beatgrids
de,nl,pt_BR,pt_PT,ro,vi Sampler
de,es,es_419,es_AR,es_CO,es_ES,es_MX,it,nl,pt_BR,ro,vi Hotcue
de,es*,it,nl,pt_BR,ro,vi Hotcue
de Loop-In Marker
de Loop-Out Marker
de,it Beatloop
Expand All @@ -399,13 +395,13 @@ de,fr,it,nl,pl Echo
de,it,nl,sv Feedback
de,nl,sl,sv Filter
de Regeneration
de,it,nl,pl,pt,pt_PT,ru,zh,zh_CN,zh_HK,zh_TW BW
de,it,nl,pl,pt,pt_PT,ru,zh* BW
de,it,lb,nn,pl,sn,sq_AL,vi Bitrate
nl Track #
de Name
de,et,fr,nb,nl,pl,ro,sl Transport
de,lt,nl,pt_BR Cues
de,es,es_419,es_AR,es_CO,es_ES,es_MX,hu,it,nl,pt_BR,ro,tr,vi,zh,zh_HK Hotcue %1
de,es*,hu,it,nl,pt_BR,ro,tr,vi,zh,zh_HK Hotcue %1
de,pt,pt_BR,vi Looping
de,hu,it,nl,sk Stop
de,fr,ru,sn Dry/Wet
Expand All @@ -423,12 +419,13 @@ de,sv Version:
de,lb,oc,pt_BR,pt_PT Linear
de,nl,vi Tags
de Sound API
de,it,ja,nl,pt,pt_BR,pt_PT,ro Deck 1
de,it,ja,nl,pt,pt_BR,pt_PT,ro Deck 2
de,it,ja,nl,pt*,ro Deck 1
de,it,ja,nl,pt*,ro Deck 2
de,it,ja,nl Deck 3
de,it,ja,nl Deck 4
de,fr,it,nl,sl fps
de,nl Decks
de,nl Track
de,nl Tracks
de Add Crate as Track Source
it legacy
nl Waveform type
74 changes: 33 additions & 41 deletions tools/ts_source_copy_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import re
import sys
import typing
import fnmatch

from lxml import etree
import githelper
Expand All @@ -18,33 +19,39 @@
)


def parse_line(line, info):
if not line.endswith("\n"):
print(f"Parse Error: No \\n at {info}")
return False
line = line[:-1]
try:
lang, source = line.split("\t", 1)
except Exception as e:
print(f"Parse Error at {info}")
print(e)
if lang is None or lang == "":
print(f"Parse Error: lang is empty at {info}")
return lang, source


def fn_match_comma_sep(language, pattern_cs):
for lang_pat in pattern_cs.split(","):
if fnmatch.fnmatchcase(language, lang_pat):
return True
return False


def is_untranstaled_allowed(source_text, language):
source_text = source_text.encode("unicode_escape").decode("utf-8")

if not os.path.exists(ALLOW_LIST_PATH):
return False

with open(ALLOW_LIST_PATH) as f:
for i, line in enumerate(f):
if not line.endswith("\n"):
print(f"Parse Error: No \\n at {ALLOW_LIST_PATH}:{i + 1}")
return False
line = line[:-1]
try:
lang, source = line.split("\t", 1)
except Exception as e:
print(f"Parse Error at {ALLOW_LIST_PATH}:{i + 1}")
print(e)
if lang is None or lang == "":
print(
f"Parse Error: lang is empty at{ALLOW_LIST_PATH}:{i + 1}"
)
continue
source = source.encode("utf-8").decode("unicode_escape")
lang, source = parse_line(line, f"{ALLOW_LIST_PATH}:{i + 1}")
if source == source_text:
if lang == "*":
return True
if language in lang:
return True

return fn_match_comma_sep(language, lang)
return False


Expand All @@ -63,26 +70,9 @@ def add_to_allow_list(source_text, language):

# Check if the source_text already exists
for i, line in enumerate(tsv_lines):
if not line.endswith("\n"):
print(f"Parse Error: No \\n at {ALLOW_LIST_PATH}:{i + 1}")
return False
line = line[:-1]
try:
lang, source = line.split("\t", 1)
except Exception as e:
print(f"Parse Error at {allow_list_path}:{i + 1}")
print(e)
if lang is None or lang == "":
print(
f"Parse Error: lang is empty at {allow_list_path}:{i + 1}"
)
continue
lang, source = parse_line(line, f"{allow_list_path}:{i + 1}")
if source == source_text:
if lang == "*":
# nothing to do
return
if language in lang:
# nothing to do
if fn_match_comma_sep(language, lang):
return
lang = lang + "," + language
tsv_lines[i] = f"{lang}\t{source}\n"
Expand Down Expand Up @@ -132,6 +122,8 @@ def check_copied_source_on_lines(rootdir, file_to_format, stylepath=None):
translation_elem = message.find("translation")
if translation_elem is None:
continue
if translation_elem.get("type") == "unfinished":
continue
translation = translation_elem.text
if source != translation:
continue
Expand Down Expand Up @@ -188,8 +180,8 @@ def main(argv: typing.Optional[typing.List[str]] = None) -> int:

if ret:
print(
"\n"
"All not allowed copied source translations need to be removed"
"\n" # For a distance to the list of findings
"All disallowed copied source translations need to be removed"
" at\n"
"https://app.transifex.com/mixxx-dj-software and pulled again.\n"
"If they are intended untranslated use:\n"
Expand Down

0 comments on commit 233777b

Please sign in to comment.