File size: 620 Bytes
1e495f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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()