-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,399 additions
and
1,327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import os | ||
import xml.etree.ElementTree as ET | ||
|
||
# Define source file path | ||
source_file = "src/main/resources/youtube/settings/host/values/strings.xml" | ||
|
||
# Define destination directory path | ||
destination_directory = "src/main/resources/youtube/translations" | ||
|
||
def parse_xml(file_path): | ||
""" | ||
Parse the XML file and return the root element. | ||
:param file_path: Path to the XML file. | ||
:return: Root element of the XML tree. | ||
""" | ||
tree = ET.parse(file_path) | ||
return tree.getroot() | ||
|
||
def get_strings_dict(root): | ||
""" | ||
Extract strings from the XML root and return them as a dictionary. | ||
:param root: Root element of the XML tree. | ||
:return: Dictionary with name attributes as keys and text as values. | ||
""" | ||
strings_dict = {} | ||
for string in root.findall('string'): | ||
name = string.get('name') | ||
text = string.text | ||
strings_dict[name] = text | ||
return strings_dict | ||
|
||
def ensure_directory_exists(directory): | ||
""" | ||
Ensure that the directory exists. If it does not, create it. | ||
:param directory: Path to the directory. | ||
""" | ||
if not os.path.exists(directory): | ||
os.makedirs(directory) | ||
|
||
def compare_and_create_missing_file(source_dict, dest_file_path): | ||
""" | ||
Compare source strings with destination strings and create a file with missing strings. | ||
:param source_dict: Dictionary of source strings. | ||
:param dest_file_path: Path to the destination XML file. | ||
""" | ||
dest_dir = os.path.dirname(dest_file_path) | ||
missing_file_path = os.path.join(dest_dir, 'missing_strings.xml') | ||
|
||
if os.path.exists(dest_file_path): | ||
dest_root = parse_xml(dest_file_path) | ||
dest_dict = get_strings_dict(dest_root) | ||
else: | ||
dest_dict = {} | ||
|
||
# Collect missing strings | ||
missing_strings = [] | ||
|
||
for name, text in source_dict.items(): | ||
if name not in dest_dict: | ||
missing_strings.append((name, text)) | ||
|
||
if missing_strings: | ||
# Create missing_strings.xml with missing strings | ||
with open(missing_file_path, 'w', encoding='utf-8') as f: | ||
f.write('<?xml version="1.0" encoding="utf-8"?>\n<resources>\n') | ||
for name, text in missing_strings: | ||
f.write(f' <string name="{name}">{text}</string>\n') | ||
f.write('</resources>\n') | ||
|
||
def main(): | ||
""" | ||
Main function to handle the XML parsing, comparison, and updating process. | ||
""" | ||
source_root = parse_xml(source_file) | ||
source_dict = get_strings_dict(source_root) | ||
|
||
for dirpath, dirnames, filenames in os.walk(destination_directory): | ||
for dirname in dirnames: | ||
lang_dir = os.path.join(dirpath, dirname) | ||
dest_file_path = os.path.join(lang_dir, 'strings.xml') | ||
compare_and_create_missing_file(source_dict, dest_file_path) | ||
|
||
if __name__ == "__main__": | ||
main() |
28 changes: 0 additions & 28 deletions
28
src/main/resources/youtube/translations/ar/missing-strings.xml
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/main/resources/youtube/translations/ar/missing_strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="revanced_extended_settings_search_title">Search settings</string> | ||
<string name="revanced_hide_shorts_comments_disabled_button_summary_off">Disabled comments button or with label \"0\" is shown.</string> | ||
<string name="revanced_hide_shorts_comments_disabled_button_summary_on">Disabled comments button or with label \"0\" is hidden.</string> | ||
<string name="revanced_hide_shorts_comments_disabled_button_title">Hide disabled comments button</string> | ||
<string name="revanced_hide_shorts_live_header_summary_off">Live chat header is shown.\n\nBack button in header won\'t be hidden.</string> | ||
<string name="revanced_hide_shorts_live_header_summary_on">Live chat header is hidden.\n\nBack button in header won\'t be hidden.</string> | ||
<string name="revanced_hide_shorts_live_header_title">Hide live chat header</string> | ||
<string name="revanced_icon_afn_blue">AFN Blue</string> | ||
<string name="revanced_icon_afn_red">AFN Red</string> | ||
<string name="revanced_icon_vanced_black">Vanced Black</string> | ||
<string name="revanced_icon_vanced_light">Vanced Light</string> | ||
<string name="revanced_return_shorts_channel_name_fetch_summary_off">"Use YouTube's built-in channel name."</string> | ||
<string name="revanced_return_shorts_channel_name_fetch_summary_on">"Use the channel name taken from RSS feed. | ||
It may take longer to fetch the channel name."</string> | ||
<string name="revanced_return_shorts_channel_name_fetch_title">Fetch from rss feed</string> | ||
<string name="revanced_spoof_client_options_entry_android">Android</string> | ||
<string name="revanced_spoof_client_options_entry_android_embedded_player">Android Embedded Player</string> | ||
<string name="revanced_spoof_client_options_entry_android_unplugged">Android TV</string> | ||
<string name="revanced_spoof_client_options_entry_tvhtml5_simply_embedded_player">TV HTML5</string> | ||
<string name="revanced_spoof_client_options_entry_web">Web</string> | ||
<string name="revanced_spoof_client_stats_for_nerds_summary_off">Spoofed client is hidden in Stats for nerds.</string> | ||
<string name="revanced_spoof_client_stats_for_nerds_summary_on">Spoofed client is shown in Stats for nerds.</string> | ||
<string name="revanced_spoof_client_stats_for_nerds_title">Show in Stats for nerds</string> | ||
</resources> |
127 changes: 0 additions & 127 deletions
127
src/main/resources/youtube/translations/bg-rBG/missing-strings.xml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.