@@ -127,11 +127,27 @@ def __init__(self, **kwargs):
127127 self .translation : Union [str , List [str ], List [TextBlock ]]
128128 self .adapted_to : Optional [List [str ]] = kwargs .get ('adapted_to' , None )
129129 self .glossaries : Optional [List [str ]] = kwargs .get ('glossaries' , None )
130- self .adapted_to_matches : Optional [Union [List [NGMemoryMatch ], List [List [NGMemoryMatch ]]]] = kwargs .get ('adapted_to_matches' , None )
131- self .glossaries_matches : Optional [Union [List [NGGlossaryMatch ], List [List [NGGlossaryMatch ]]]] = kwargs .get ('glossaries_matches' , None )
130+ self .adapted_to_matches : Optional [Union [List [NGMemoryMatch ], List [List [NGMemoryMatch ]]]] = None
131+ self .glossaries_matches : Optional [Union [List [NGGlossaryMatch ], List [List [NGGlossaryMatch ]]]] = None
132+
133+ # Parse adapted_to_matches
134+ adapted_to_matches = kwargs .get ('adapted_to_matches' , None )
135+ if adapted_to_matches is not None :
136+ if adapted_to_matches and isinstance (adapted_to_matches [0 ], list ):
137+ self .adapted_to_matches = [[NGMemoryMatch (** m ) for m in matches ] for matches in adapted_to_matches ]
138+ else :
139+ self .adapted_to_matches = [NGMemoryMatch (** m ) for m in adapted_to_matches ]
132140
133- translation = kwargs .get ('translation' )
141+ # Parse glossaries_matches
142+ glossaries_matches = kwargs .get ('glossaries_matches' , None )
143+ if glossaries_matches is not None :
144+ if glossaries_matches and isinstance (glossaries_matches [0 ], list ):
145+ self .glossaries_matches = [[NGGlossaryMatch (** m ) for m in matches ] for matches in glossaries_matches ]
146+ else :
147+ self .glossaries_matches = [NGGlossaryMatch (** m ) for m in glossaries_matches ]
134148
149+ # Parse translation
150+ translation = kwargs .get ('translation' )
135151 if isinstance (translation , str ):
136152 self .translation = translation
137153 elif isinstance (translation , list ):
0 commit comments