from environment import TEST_DATA def read_translation(language, count_limit=None): if language == "zh": text_file = TEST_DATA/"texts"/"test_translation_zh.txt" elif language == "en": text_file = TEST_DATA/"texts"/"test_translation_en.txt" else: raise ValueError(f"not support language: {language}") count = 0 with open(text_file, encoding="utf-8") as f: for line in f: if not line.strip(): continue count += 1 if count_limit is not None and count > count_limit: break yield line.strip()