Skip to content

Commit

Permalink
fix(YouTube - Translations): Update translations info
Browse files Browse the repository at this point in the history
ar - 19 missing strings, 8 updated strings.
bg-rBG - 64 missing strings, 8 updated strings.
bn - 255 missing strings, 8 updated strings.
de-rDE - 317 missing strings, 8 updated strings.
el-rGR - 32 missing strings, 8 updated strings.
es-rES - 0 missing strings, 8 updated strings.
fi-rFI - 256 missing strings, 8 updated strings.
fr-rFR - 12 missing strings, 8 updated strings.
hu-rHU - 32 missing strings, 8 updated strings.
id-rID - 188 missing strings, 8 updated strings.
in - 188 missing strings, 8 updated strings.
it-rIT - 0 missing strings, 1 updated strings.
ja-rJP - 0 missing strings, 1 updated strings.
ko-rKR - 0 missing strings, 1 updated strings.
pl-rPL - 0 missing strings, 1 updated strings.
pt-rBR - 9 missing strings, 4 updated strings.
ru-rRU - 9 missing strings, 4 updated strings.
tr-rTR - 32 missing strings, 8 updated strings.
uk-rUA - 9 missing strings, 4 updated strings.
vi-rVN - 32 missing strings, 8 updated strings.
zh-rCN - 215 missing strings, 8 updated strings.
zh-rTW - 37 missing strings, 8 updated strings.
  • Loading branch information
anddea committed Mar 25, 2024
1 parent 9abf946 commit 36b1ed4
Show file tree
Hide file tree
Showing 44 changed files with 165 additions and 97 deletions.
154 changes: 96 additions & 58 deletions search_for_missing_strings.py
Expand Up @@ -18,64 +18,102 @@ def extract_strings(file_path):
# 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.")
def add_string_to_files(string):
for root, dirs, files in os.walk(destination_directory):
if "strings.xml" in files:
# Get destination file path
destination_file = os.path.join(root, "updated-strings.xml")
with open(destination_file, 'a') as f:
# Split the multiline string into lines, strip leading whitespace from each line, and join them back
stripped_lines = '\n'.join(line.strip() for line in string.split('\n'))
f.write(stripped_lines + '\n')

# Function to find missing strings
def find_missing_strings():
num_missing = 0 # Initialize num_missing to 0
num_updated = 0 # Initialize num_updated to 0

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

# Locate updated-strings.xml file
updated_strings_file = os.path.join(destination_folder, "updated-strings.xml")

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

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

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

# Extract strings from updated-strings.xml if exists
if os.path.isfile(updated_strings_file):
updated_strings = extract_strings(updated_strings_file)
# Count name attributes in updated strings
num_updated = sum(1 for name, _, _ in updated_strings)

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

num_missing = 0
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 the result
print(f"{language_code} - {num_missing} missing strings, {num_updated} updated strings.")

# If there are no arguments, call the original script
if len(sys.argv) == 1:
find_missing_strings()

# If the argument is -n, call the string addition function
elif len(sys.argv) == 3 and sys.argv[1] == '-n':
string = sys.argv[2]
add_string_to_files(string)

# If neither condition is met, print a warning
else:
print("Invalid arguments. Usage:")
print("To run original script: script.py")
print("To add a string to files: script.py -n 'string'")

# Prompt the user to press a key before closing the terminal window
input("\nPress Enter to exit...")
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/youtube/settings/host/values/strings.xml
Expand Up @@ -101,7 +101,7 @@ Note: This feature hasn't been tested."</string>
<string name="revanced_hide_keyword_content_sub_summary_off">Keyword filter for subscriptions is disabled.</string>
<string name="revanced_hide_keyword_content_sub_summary_on">Keyword filter for subscriptions is enabled.</string>
<string name="revanced_hide_keyword_content_sub_title">Enable subscriptions keyword filter</string>
<string name="revanced_hide_keyword_content_about_summary">Search/Home/Subscription results are filtered to hide content that matches keyword phrases\n\nLimitations\n• Some Shorts may not be hidden\n• Some UI components may not be hidden\n• Searching for a keyword may show no results</string>
<string name="revanced_hide_keyword_content_about_summary">Search, Home, Subscription and Comments are filtered to hide content that matches keyword phrases\n\nLimitations\n• Some Shorts may not be hidden\n• Some UI components may not be hidden\n• Searching for a keyword may show no results</string>
<string name="revanced_hide_keyword_toast_invalid_common" formatted="false">Invalid keyword. Cannot use: \'%s\' as a filter</string>
<string name="revanced_hide_keyword_toast_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\n\nWords with uppercase letters in the middle must be entered with the casing (ie: iPhone, TikTok, LeBlanc).</string>
Expand Down Expand Up @@ -746,7 +746,7 @@ Some videos, including those from channels you subscribe to, may not be hidden e
<string name="revanced_hook_download_button_summary">"Replace download button with external download button."</string>
<string name="revanced_hook_download_button_title">Hook download button</string>
<string name="revanced_inform">Inform</string>
<string name="revanced_keep_landscape_mode_summary">Keeps landscape mode when turning the screen off and on in fullscreen.</string>
<string name="revanced_keep_landscape_mode_summary">Keeps landscape mode when turning the screen off and on in fullscreen.\n\nKnown issue: It can break Picture-in-Picture (PIP).</string>
<string name="revanced_keep_landscape_mode_timeout_summary">The amount of milliseconds the landscape mode is forced.</string>
<string name="revanced_keep_landscape_mode_timeout_title">Keep landscape mode timeout</string>
<string name="revanced_keep_landscape_mode_title">Keep landscape mode</string>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/youtube/settings/xml/revanced_prefs.xml
Expand Up @@ -645,7 +645,7 @@
<Preference android:title=" " android:selectable="false" android:summary="@string/pref_about_category" />
<PreferenceScreen android:title="@string/revanced_patches_information" android:summary="@string/revanced_patches_information_summary" >
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_tool_used" />
<Preference android:title="ReVanced Patches" android:selectable="false" android:summary="2.222.0-dev.6" />
<Preference android:title="ReVanced Patches" android:selectable="false" android:summary="2.223.0-dev.1" />
<Preference android:title="ReVanced Integrations" android:selectable="false" android:summary="" />

<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_ads" />
Expand Down
@@ -1,5 +1,5 @@
<string name="revanced_alt_thumbnail_dearrow_api_url_summary">"The URL of the DeArrow thumbnail cache endpoint. Do not change this unless you know what you're doing."</string>
<string name="revanced_hide_keyword_content_about_summary">Search/Home/Subscription results are filtered to hide content that matches keyword phrases\n\nLimitations\n• Some Shorts may not be hidden\n• Some UI components may not be hidden\n• Searching for a keyword may show no results</string>
<string name="revanced_hide_keyword_content_about_summary">Search, Home, Subscription and Comments are filtered to hide content that matches keyword phrases\n\nLimitations\n• Some Shorts may not be hidden\n• Some UI components may not be hidden\n• Searching for a keyword may show no results</string>
<string name="revanced_hide_keyword_content_comment_summary_off">Keyword filter for comments is disabled.</string>
<string name="revanced_hide_keyword_content_comment_summary_on">Keyword filter for comments is enabled.</string>
<string name="revanced_hide_keyword_content_comment_title">Enable comments keyword filter</string>
Expand Down
Expand Up @@ -13,3 +13,5 @@
<string name="revanced_hide_keyword_content_feed_summary_on">Keyword filter for feed and search is enabled.</string>

<string name="revanced_keyword_filter_summary">Hides videos using keyword filter.</string>

<string name="revanced_keep_landscape_mode_summary">Keeps landscape mode when turning the screen off and on in fullscreen.\n\nKnown issue: It can break Picture-in-Picture (PIP).</string>
Expand Up @@ -13,7 +13,7 @@
<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_keyword_content_about_summary">Search/Home/Subscription results are filtered to hide content that matches keyword phrases\n\nLimitations\n• Some Shorts may not be hidden\n• Some UI components may not be hidden\n• Searching for a keyword may show no results</string>
<string name="revanced_hide_keyword_content_about_summary">Search, Home, Subscription and Comments are filtered to hide content that matches keyword phrases\n\nLimitations\n• Some Shorts may not be hidden\n• Some UI components may not be hidden\n• Searching for a keyword may show no results</string>
<string name="revanced_hide_keyword_content_comment_summary_off">Keyword filter for comments is disabled.</string>
<string name="revanced_hide_keyword_content_comment_summary_on">Keyword filter for comments is enabled.</string>
<string name="revanced_hide_keyword_content_comment_title">Enable comments keyword filter</string>
Expand Down
Expand Up @@ -13,3 +13,5 @@
<string name="revanced_hide_keyword_content_feed_summary_on">Keyword filter for feed and search is enabled.</string>

<string name="revanced_keyword_filter_summary">Hides videos using keyword filter.</string>

<string name="revanced_keep_landscape_mode_summary">Keeps landscape mode when turning the screen off and on in fullscreen.\n\nKnown issue: It can break Picture-in-Picture (PIP).</string>
Expand Up @@ -132,7 +132,7 @@ Some components may not be hidden."</string>
<string name="revanced_hide_for_you_shelf_title">"Hide 'For You' shelf"</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_keyword_content_about_summary">Search/Home/Subscription results are filtered to hide content that matches keyword phrases\n\nLimitations\n• Some Shorts may not be hidden\n• Some UI components may not be hidden\n• Searching for a keyword may show no results</string>
<string name="revanced_hide_keyword_content_about_summary">Search, Home, Subscription and Comments are filtered to hide content that matches keyword phrases\n\nLimitations\n• Some Shorts may not be hidden\n• Some UI components may not be hidden\n• Searching for a keyword may show no results</string>
<string name="revanced_hide_keyword_content_comment_summary_off">Keyword filter for comments is disabled.</string>
<string name="revanced_hide_keyword_content_comment_summary_on">Keyword filter for comments is enabled.</string>
<string name="revanced_hide_keyword_content_comment_title">Enable comments keyword filter</string>
Expand Down Expand Up @@ -187,7 +187,7 @@ Videos with a gray description include videos that are not related to search ter
Some videos, including those from channels you subscribe to, may not be hidden even if they have fewer than 1,000 views."</string>
<string name="revanced_hide_video_with_low_view_title">Hide videos with low views</string>
<string name="revanced_inform">Inform</string>
<string name="revanced_keep_landscape_mode_summary">Keeps landscape mode when turning the screen off and on in fullscreen.</string>
<string name="revanced_keep_landscape_mode_summary">Keeps landscape mode when turning the screen off and on in fullscreen.\n\nKnown issue: It can break Picture-in-Picture (PIP).</string>
<string name="revanced_keep_landscape_mode_timeout_summary">The amount of milliseconds the landscape mode is forced.</string>
<string name="revanced_keep_landscape_mode_timeout_title">Keep landscape mode timeout</string>
<string name="revanced_keep_landscape_mode_title">Keep landscape mode</string>
Expand Down
Expand Up @@ -13,3 +13,5 @@
<string name="revanced_hide_keyword_content_feed_summary_on">Keyword filter for feed and search is enabled.</string>

<string name="revanced_keyword_filter_summary">Hides videos using keyword filter.</string>

<string name="revanced_keep_landscape_mode_summary">Keeps landscape mode when turning the screen off and on in fullscreen.\n\nKnown issue: It can break Picture-in-Picture (PIP).</string>
Expand Up @@ -52,7 +52,7 @@ Some components may not be hidden."</string>
<string name="revanced_hide_handle_title">Hide handle</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_keyword_content_about_summary">Search/Home/Subscription results are filtered to hide content that matches keyword phrases\n\nLimitations\n• Some Shorts may not be hidden\n• Some UI components may not be hidden\n• Searching for a keyword may show no results</string>
<string name="revanced_hide_keyword_content_about_summary">Search, Home, Subscription and Comments are filtered to hide content that matches keyword phrases\n\nLimitations\n• Some Shorts may not be hidden\n• Some UI components may not be hidden\n• Searching for a keyword may show no results</string>
<string name="revanced_hide_keyword_content_comment_summary_off">Keyword filter for comments is disabled.</string>
<string name="revanced_hide_keyword_content_comment_summary_on">Keyword filter for comments is enabled.</string>
<string name="revanced_hide_keyword_content_comment_title">Enable comments keyword filter</string>
Expand Down Expand Up @@ -145,7 +145,7 @@ Some videos, including those from channels you subscribe to, may not be hidden e
<string name="revanced_hide_web_search_results_title">Hide web search results</string>
<string name="revanced_hook_download_button_title">Hook download button</string>
<string name="revanced_inform">Inform</string>
<string name="revanced_keep_landscape_mode_summary">Keeps landscape mode when turning the screen off and on in fullscreen.</string>
<string name="revanced_keep_landscape_mode_summary">Keeps landscape mode when turning the screen off and on in fullscreen.\n\nKnown issue: It can break Picture-in-Picture (PIP).</string>
<string name="revanced_keep_landscape_mode_timeout_summary">The amount of milliseconds the landscape mode is forced.</string>
<string name="revanced_keep_landscape_mode_timeout_title">Keep landscape mode timeout</string>
<string name="revanced_keep_landscape_mode_title">Keep landscape mode</string>
Expand Down
Expand Up @@ -13,3 +13,5 @@
<string name="revanced_hide_keyword_content_feed_summary_on">Keyword filter for feed and search is enabled.</string>

<string name="revanced_keyword_filter_summary">Hides videos using keyword filter.</string>

<string name="revanced_keep_landscape_mode_summary">Keeps landscape mode when turning the screen off and on in fullscreen.\n\nKnown issue: It can break Picture-in-Picture (PIP).</string>
Expand Up @@ -5,7 +5,7 @@
<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_hide_keyword_content_about_summary">Search/Home/Subscription results are filtered to hide content that matches keyword phrases\n\nLimitations\n• Some Shorts may not be hidden\n• Some UI components may not be hidden\n• Searching for a keyword may show no results</string>
<string name="revanced_hide_keyword_content_about_summary">Search, Home, Subscription and Comments are filtered to hide content that matches keyword phrases\n\nLimitations\n• Some Shorts may not be hidden\n• Some UI components may not be hidden\n• Searching for a keyword may show no results</string>
<string name="revanced_hide_keyword_content_comment_summary_off">Keyword filter for comments is disabled.</string>
<string name="revanced_hide_keyword_content_comment_summary_on">Keyword filter for comments is enabled.</string>
<string name="revanced_hide_keyword_content_comment_title">Enable comments keyword filter</string>
Expand Down
Expand Up @@ -13,3 +13,5 @@
<string name="revanced_hide_keyword_content_feed_summary_on">Keyword filter for feed and search is enabled.</string>

<string name="revanced_keyword_filter_summary">Hides videos using keyword filter.</string>

<string name="revanced_keep_landscape_mode_summary">Keeps landscape mode when turning the screen off and on in fullscreen.\n\nKnown issue: It can break Picture-in-Picture (PIP).</string>

0 comments on commit 36b1ed4

Please sign in to comment.