1#!/usr/bin/env python3
2import os
3
4"""
5Please add the translation language you want to add here, while also modifying the variable URL_BASE in _ext/link_roles.py
6For example:
7
8LANGUAGE =  ':link_to_translation:`zh_CN:[中文]`\t'  + \
9            ':link_to_translation:`en:[English]`\t' + \
10            '\n\n'
11
12
13URL_BASE = {
14    "zh_CN": "https://lvgl.100ask.net/",
15    "en": "https://docs.lvgl.io/"
16}
17"""
18
19LANGUAGE =  ':link_to_translation:`zh_CN:[中文]`\t'  + \
20            '\n\n'
21
22
23
24def find_files(dir_path, suffix):
25    files = []
26
27    for root, _, filenames in os.walk(dir_path):
28        for filename in filenames:
29            if filename.endswith(suffix):
30                files.append(os.path.join(root, filename))
31    return files
32
33
34
35def exec(temp_directory):
36    """
37    files = find_files(temp_directory, '.rst')
38
39    for rst_file in files:
40        with open(rst_file, 'r+', encoding='utf-8') as f:
41            content = f.read()
42            f.seek(0, 0)
43            f.write(LANGUAGE + content)
44    """
45
46    rst_file = os.path.join(temp_directory, 'index.rst')
47    with open(rst_file, 'r+', encoding='utf-8') as f:
48        content = f.read()
49        f.seek(0, 0)
50        f.write(LANGUAGE + content)
51