Skip to content

Commit

Permalink
fix(YouTube - Translations): Update translations info
Browse files Browse the repository at this point in the history
  • Loading branch information
anddea committed Mar 18, 2024
1 parent 1c3731d commit c30c031
Show file tree
Hide file tree
Showing 24 changed files with 639 additions and 518 deletions.
77 changes: 77 additions & 0 deletions search_for_missing_strings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import os
import re

# 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"

# Function to extract strings from a file
def extract_strings(file_path):
with open(file_path, 'r') as file:
content = file.read()
strings = re.findall(r'<string(?:\s+name="([^"]*)")?(.*?)>(.*?)</string>', content, re.DOTALL)
return set(strings)

# Extract strings from source file
source_strings = extract_strings(source_file)

# Loop through destination folders
# If you want to search only one language folder add +"/your_lang" to destination_directory
# like this => for root, dirs, files in os.walk(destination_directory+"/ar"):
for root, dirs, files in os.walk(destination_directory):
if "strings.xml" in files:
# Get destination file path
destination_file = os.path.join(root, "strings.xml")

# Get destination folder name (language code)
destination_folder = os.path.dirname(destination_file)
language_code = os.path.basename(destination_folder)

# Output file path
output_file = os.path.join(destination_folder, "missing_strings.xml")

# Check if source and destination files exist
if not os.path.isfile(source_file):
print(f"Error: {source_file} not found.")
exit(1)

if not os.path.isfile(destination_file):
print(f"Error: {destination_file} not found.")
exit(1)

# Extract strings from destination file
destination_strings = extract_strings(destination_file)

# Find missing strings
missing_strings = []

for name, attributes, content in source_strings:
if name not in {name for name, _, _ in destination_strings}:
string_tag = f'<string'
if name:
string_tag += f' name="{name}"'
if attributes:
string_tag += f' {attributes.strip()}'
string_tag += f'>{content}</string>\n'
missing_strings.append(string_tag)

# Sort missing strings by name attribute
missing_strings.sort(key=lambda x: re.search(r'name="([^"]*)"', x).group(1))

# Check if missing strings exist
if not missing_strings:
# Delete output file if exists
if os.path.isfile(output_file):
os.remove(output_file)

print(f"No missing strings for {language_code}")
else:
# Save missing strings to output file
with open(output_file, 'w') as file:
for string_tag in missing_strings:
file.write(string_tag)

num_missing = len(missing_strings)
print(f"{language_code} - {num_missing} missing strings.")
66 changes: 0 additions & 66 deletions search_for_missing_strings.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<string name="revanced_spoof_failure_connection_status_code" formatted="false">"Spoof storyboard not available: "</string>
<string name="revanced_spoof_failure_connection_timeout">Spoof storyboard temporarily not available (API timed out).</string>
<string name="revanced_spoof_failure_generic">"Spoof storyboard temporarily not available: "</string>
<string name="revanced_swipe_overlay_rect_warning" formatted="false">Swiapeable area size can't be more than %s%%. Reset to default value.</string>
<string name="revanced_swipe_overlay_rect_summary">Percentage of swipeable screen area.</string>
<string name="revanced_swipe_overlay_rect_title">Swipe overlay screen size</string>
<string name="revanced_swipe_overlay_rect_title">Swipe overlay screen size</string>
<string name="revanced_swipe_overlay_rect_warning" formatted="false">Swipeable area size can\'t be more than %s%%. Reset to default value.</string>
41 changes: 20 additions & 21 deletions src/main/resources/youtube/translations/bg-rBG/missing_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,52 @@
<string name="revanced_change_start_page_entry_music">Music</string>
<string name="revanced_change_start_page_entry_sports">Sports</string>
<string name="revanced_change_start_page_entry_watch_later">Watch later</string>
<string name="revanced_keyword_invalid_length" formatted="false">Invalid keyword length (must be at least %s characters): %s.</string>
<string name="revanced_keyword_filter_strings_summary">Configure keywords and phrases to hide, separated by new lines

Words with uppercase letters in the middle must be entered with the casing (ie: iPhone, TikTok, LeBlanc).</string>
<string name="revanced_keyword_filter_strings_title">Edit keyword filter</string>
<string name="revanced_keyword_filter_summary_off">Keyword filter is disabled.</string>
<string name="revanced_keyword_filter_summary_on">Keyword filter is enabled.</string>
<string name="revanced_keyword_filter_summary">Hides feed and search result videos using keyword filters.</string>
<string name="revanced_keyword_filter_title">Enable keyword filter</string>
<string name="revanced_disable_rolling_number_animations_summary_off">Rolling animations are enabled.</string>
<string name="revanced_disable_rolling_number_animations_summary_on">Rolling animations are disabled.</string>
<string name="revanced_disable_rolling_number_animations_title">Disable rolling number animations</string>
<string name="revanced_hide_community_posts_related_video_summary_off">Community posts in related video are shown.</string>
<string name="revanced_hide_community_posts_related_video_summary_on">Community posts in related video are hidden.</string>
<string name="revanced_hide_community_posts_related_video_title">Hide community posts in related video</string>
<string name="revanced_hide_home_feed_membership_video_summary">Hide videos with \"Only for Membership\" tag in Home Feed</string>
<string name="revanced_hide_home_feed_membership_video_title">Hide membership videos in Home Feed</string>
<string name="revanced_hide_suggested_video_overlay_auto_play_summary">When you finished a video, another play automatically</string>
<string name="revanced_hide_suggested_video_overlay_auto_play_title">Auto play the next video</string>
<string name="revanced_hide_home_feed_membership_video_summary">Hide videos with "Only for Membership" tag in Home Feed</string>
<string name="revanced_hide_home_feed_membership_video_title">Hide membership videos in Home Feed</string>
<string name="revanced_keyword_filter_strings_summary">Configure keywords and phrases to hide, separated by new lines\n\nWords with uppercase letters in the middle must be entered with the casing (ie: iPhone, TikTok, LeBlanc).</string>
<string name="revanced_keyword_filter_strings_title">Edit keyword filter</string>
<string name="revanced_keyword_filter_summary">Hides feed and search result videos using keyword filters.</string>
<string name="revanced_keyword_filter_summary_off">Keyword filter is disabled.</string>
<string name="revanced_keyword_filter_summary_on">Keyword filter is enabled.</string>
<string name="revanced_keyword_filter_title">Enable keyword filter</string>
<string name="revanced_keyword_invalid_length" formatted="false">Invalid keyword length (must be at least %s characters): %s.</string>
<string name="revanced_overlay_button_time_ordered_playlist_summary">"Tap to generate a playlist of all videos from channel from oldest to newest.
Tap and hold to undo."</string>
<string name="revanced_overlay_button_time_ordered_playlist_title">Time-ordered playlist button</string>
<string name="revanced_overlay_button_whitelisting_summary">Tap to launch add channel into Channel Whitelist.</string>
<string name="revanced_overlay_button_whitelisting_title">Whitelist button</string>
<string name="revanced_override_premium_header_summary_off">Current Header: Default Header</string>
<string name="revanced_override_premium_header_summary_on">Current Header: Premium Header</string>
<string name="revanced_override_premium_header_title">Premium Header</string>
<string name="revanced_whitelisting_added" formatted="false">Channel %s was added to the %s whitelist</string>
<string name="revanced_spoof_app_version_target_entry_16_08_35">16.08.35 - Restore old explore tab</string>
<string name="revanced_spoof_app_version_target_entry_18_09_39">18.09.39 - Restore old library tab (Disable You Tab)</string>
<string name="revanced_spoof_failure_connection_status_code" formatted="false">"Spoof storyboard not available: "</string>
<string name="revanced_spoof_failure_connection_timeout">Spoof storyboard temporarily not available (API timed out).</string>
<string name="revanced_spoof_failure_generic">"Spoof storyboard temporarily not available: "</string>
<string name="revanced_swipe_overlay_rect_summary">Percentage of swipeable screen area.</string>
<string name="revanced_swipe_overlay_rect_title">Swipe overlay screen size</string>
<string name="revanced_swipe_overlay_rect_warning" formatted="false">Swipeable area size can\'t be more than %s%%. Reset to default value.</string>
<string name="revanced_whitelisting_add_failed" formatted="false">Failed to add channel %s to the %s whitelist</string>
<string name="revanced_whitelisting_added" formatted="false">Channel %s was added to the %s whitelist</string>
<string name="revanced_whitelisting_channel_name">Channel Name</string>
<string name="revanced_whitelisting_empty">There are no whitelisted channels</string>
<string name="revanced_whitelisting_excluded">Not added to whitelist</string>
<string name="revanced_whitelisting_fetch_failed" formated="false">Failed to retrieve channel details, received message %d</string>
<string name="revanced_whitelisting_included">Added to whitelist</string>
<string name="revanced_whitelisting_reboot">Reboot to apply channel whitelist settings</string>
<string name="revanced_whitelisting_removed" formatted="false">Channel %s was removed from the %s whitelist</string>
<string name="revanced_whitelisting_remove_failed" formatted="false">Failed to remove channel %s from the %s whitelist</string>
<string name="revanced_whitelisting_removed" formatted="false">Channel %s was removed from the %s whitelist</string>
<string name="revanced_whitelisting_settings_summary">Check or remove the list of channels added to the whitelist</string>
<string name="revanced_whitelisting_speed">Video Speed</string>
<string name="revanced_whitelisting_speed_button">Speed</string>
<string name="revanced_whitelisting_sponsorblock">SponsorBlock</string>
<string name="revanced_whitelisting_sponsorblock_button">SB</string>
<string name="revanced_whitelisting_title">Channel Whitelist</string>
<string name="revanced_spoof_app_version_target_entry_16_08_35">16.08.35 - Restore old explore tab</string>
<string name="revanced_spoof_app_version_target_entry_18_09_39">18.09.39 - Restore old library tab (Disable You Tab)</string>
<string name="revanced_spoof_failure_connection_status_code" formatted="false">"Spoof storyboard not available: "</string>
<string name="revanced_spoof_failure_connection_timeout">Spoof storyboard temporarily not available (API timed out).</string>
<string name="revanced_spoof_failure_generic">"Spoof storyboard temporarily not available: "</string>
<string name="revanced_swipe_overlay_rect_warning" formatted="false">Swiapeable area size can't be more than %s%%. Reset to default value.</string>
<string name="revanced_swipe_overlay_rect_summary">Percentage of swipeable screen area.</string>
<string name="revanced_swipe_overlay_rect_title">Swipe overlay screen size</string>
Loading

0 comments on commit c30c031

Please sign in to comment.