| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -9,6 +9,7 @@ UI_DIR = os.path.join(BASEDIR, "selfdrive", "ui") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					TRANSLATIONS_DIR = os.path.join(UI_DIR, "translations") | 
					 | 
					 | 
					 | 
					TRANSLATIONS_DIR = os.path.join(UI_DIR, "translations") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					LANGUAGES_FILE = os.path.join(TRANSLATIONS_DIR, "languages.json") | 
					 | 
					 | 
					 | 
					LANGUAGES_FILE = os.path.join(TRANSLATIONS_DIR, "languages.json") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					TRANSLATIONS_INCLUDE_FILE = os.path.join(TRANSLATIONS_DIR, "alerts_generated.h") | 
					 | 
					 | 
					 | 
					TRANSLATIONS_INCLUDE_FILE = os.path.join(TRANSLATIONS_DIR, "alerts_generated.h") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					PLURAL_ONLY = ["main_en"]  # base language, only create entries for strings with plural forms | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					def generate_translations_include(): | 
					 | 
					 | 
					 | 
					def generate_translations_include(): | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -22,21 +23,20 @@ def generate_translations_include(): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  with open(TRANSLATIONS_INCLUDE_FILE, "w") as f: | 
					 | 
					 | 
					 | 
					  with open(TRANSLATIONS_INCLUDE_FILE, "w") as f: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    f.write(content) | 
					 | 
					 | 
					 | 
					    f.write(content) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					def update_translations(vanish=False, plural_only=None, translations_dir=TRANSLATIONS_DIR): | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  generate_translations_include() | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  if plural_only is None: | 
					 | 
					 | 
					 | 
					def update_translations(vanish: bool = False, translation_files: None | list[str] = None, translations_dir: str = TRANSLATIONS_DIR): | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    plural_only = [] | 
					 | 
					 | 
					 | 
					  generate_translations_include() | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  with open(LANGUAGES_FILE, "r") as f: | 
					 | 
					 | 
					 | 
					  if translation_files is None: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    translation_files = json.load(f) | 
					 | 
					 | 
					 | 
					    with open(LANGUAGES_FILE, "r") as f: | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      translation_files = json.load(f).values() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  for file in translation_files.values(): | 
					 | 
					 | 
					 | 
					  for file in translation_files: | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    tr_file = os.path.join(translations_dir, f"{file}.ts") | 
					 | 
					 | 
					 | 
					    tr_file = os.path.join(translations_dir, f"{file}.ts") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    args = f"lupdate -locations none -recursive {UI_DIR} -ts {tr_file} -I {BASEDIR}" | 
					 | 
					 | 
					 | 
					    args = f"lupdate -locations none -recursive {UI_DIR} -ts {tr_file} -I {BASEDIR}" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if vanish: | 
					 | 
					 | 
					 | 
					    if vanish: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      args += " -no-obsolete" | 
					 | 
					 | 
					 | 
					      args += " -no-obsolete" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if file in plural_only: | 
					 | 
					 | 
					 | 
					    if file in PLURAL_ONLY: | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      args += " -pluralonly" | 
					 | 
					 | 
					 | 
					      args += " -pluralonly" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ret = os.system(args) | 
					 | 
					 | 
					 | 
					    ret = os.system(args) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    assert ret == 0 | 
					 | 
					 | 
					 | 
					    assert ret == 0 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -46,8 +46,6 @@ if __name__ == "__main__": | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  parser = argparse.ArgumentParser(description="Update translation files for UI", | 
					 | 
					 | 
					 | 
					  parser = argparse.ArgumentParser(description="Update translation files for UI", | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                   formatter_class=argparse.ArgumentDefaultsHelpFormatter) | 
					 | 
					 | 
					 | 
					                                   formatter_class=argparse.ArgumentDefaultsHelpFormatter) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  parser.add_argument("--vanish", action="store_true", help="Remove translations with source text no longer found") | 
					 | 
					 | 
					 | 
					  parser.add_argument("--vanish", action="store_true", help="Remove translations with source text no longer found") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  parser.add_argument("--plural-only", type=str, nargs="*", default=["main_en"], | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                      help="Translation codes to only create plural translations for (ie. the base language)") | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  args = parser.parse_args() | 
					 | 
					 | 
					 | 
					  args = parser.parse_args() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  update_translations(args.vanish, args.plural_only) | 
					 | 
					 | 
					 | 
					  update_translations(args.vanish) | 
				
			
			
				
				
			
		
	
		
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					 | 
					
  |