|  |  | @ -67,11 +67,14 @@ class TestTranslations(unittest.TestCase): | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.assertTrue("<translation type=\"vanished\">" not in cur_translations, |  |  |  |         self.assertTrue("<translation type=\"vanished\">" not in cur_translations, | 
			
		
	
		
		
			
				
					
					|  |  |  |                         f"{file} ({name}) translation file has obsolete translations. Run selfdrive/ui/update_translations.py --vanish to remove them") |  |  |  |                         f"{file} ({name}) translation file has obsolete translations. Run selfdrive/ui/update_translations.py --vanish to remove them") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def test_plural_translations(self): |  |  |  |   def test_finished_translations(self): | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     """ |  |  |  |     """ | 
			
		
	
		
		
			
				
					
					|  |  |  |       Tests: |  |  |  |       Tests ran on each translation marked "finished" | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |       - that any numerus (plural) translations marked "finished" have all plural forms non-empty |  |  |  |       Plural: | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       - that any numerus (plural) translations have all plural forms non-empty | 
			
		
	
		
		
			
				
					
					|  |  |  |       - that the correct format specifier is used (%n) |  |  |  |       - that the correct format specifier is used (%n) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       Non-plural: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       - that translation is not empty | 
			
		
	
		
		
			
				
					
					|  |  |  |     """ |  |  |  |     """ | 
			
		
	
		
		
			
				
					
					|  |  |  |     for name, file in self.translation_files.items(): |  |  |  |     for name, file in self.translation_files.items(): | 
			
		
	
		
		
			
				
					
					|  |  |  |       with self.subTest(name=name, file=file): |  |  |  |       with self.subTest(name=name, file=file): | 
			
		
	
	
		
		
			
				
					|  |  | @ -79,17 +82,23 @@ class TestTranslations(unittest.TestCase): | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         for context in tr_xml.getroot(): |  |  |  |         for context in tr_xml.getroot(): | 
			
		
	
		
		
			
				
					
					|  |  |  |           for message in context.iterfind("message"): |  |  |  |           for message in context.iterfind("message"): | 
			
		
	
		
		
			
				
					
					|  |  |  |             if message.get("numerus") == "yes": |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             translation = message.find("translation") |  |  |  |             translation = message.find("translation") | 
			
		
	
		
		
			
				
					
					|  |  |  |               numerusform = [t.text for t in translation.findall("numerusform")] |  |  |  |             source_text = message.find("source").text | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |               # Do not assert finished translations |  |  |  |             # Do not test unfinished translations | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             if translation.get("type") == "unfinished": |  |  |  |             if translation.get("type") == "unfinished": | 
			
		
	
		
		
			
				
					
					|  |  |  |               continue |  |  |  |               continue | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |               self.assertNotIn(None, numerusform, "Ensure all plural translation forms are completed.") |  |  |  |             if message.get("numerus") == "yes": | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |               self.assertTrue(all(re.search("%[0-9]+", t) is None for t in numerusform), |  |  |  |               numerusform = [t.text for t in translation.findall("numerusform")] | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                               "Plural translations must use %n, not %1, %2, etc.: {}".format(numerusform)) |  |  |  | 
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               for nf in numerusform: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 self.assertIsNotNone(nf, f"Ensure all plural translation forms are completed: {source_text}") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 self.assertIn("%n", nf, "Ensure numerus argument (%n) exists in translation.") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 self.assertIsNone(re.search("%[0-9]+", nf), "Plural translations must use %n, not %1, %2, etc.: {}".format(numerusform)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             else: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               self.assertIsNotNone(translation.text, f"Ensure translation is completed: {source_text}") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def test_no_locations(self): |  |  |  |   def test_no_locations(self): | 
			
		
	
		
		
			
				
					
					|  |  |  |     for name, file in self.translation_files.items(): |  |  |  |     for name, file in self.translation_files.items(): | 
			
		
	
	
		
		
			
				
					|  |  | 
 |