Invidious is an alternative front-end to YouTube
Add ability to propagate locale removals
syeopited4327329596c
diff --git a/scripts/propagate-new-locale-keys.cr b/scripts/propagate-new-locale-keys.crindex 39910c6e..570b408a 100644--- a/scripts/propagate-new-locale-keys.cr+++ b/scripts/propagate-new-locale-keys.cr@@ -20,7 +20,7 @@ end# Invidious currently has some unloaded localization files. We shouldn't need to propagate new keys onto those.# We'll also remove the reference locale (english) from the list to process.loaded_locales = LOCALES.keys.select! { |key| key != "en-US" }-english_locale = locale_to_array("en-US")[0]+english_locale, english_locale_keys = locale_to_array("en-US")# In order to automatically propagate locale keys we're going to be needing two arrays.# One is an array containing each locale data encoded as tuples. The other would contain@@ -39,7 +39,8 @@ loaded_locales.each do |name|locale_list_with_only_keys << keys_only_localeend-locale_list_with_only_keys.each_with_index do |keys_of_locale_in_processing, index_of_locale_in_processing|+# Propagate additions+locale_list_with_only_keys.dup.each_with_index do |keys_of_locale_in_processing, index_of_locale_in_processing|insert_at = {} of Int32 => Tuple(String, JSON::Any | String)LOCALES["en-US"].each_with_index do |ref_locale_data, ref_locale_key_index|@@ -57,10 +58,27 @@ locale_list_with_only_keys.each_with_index do |keys_of_locale_in_processing, indendinsert_at.each do |location_to_insert, data|+ locale_list_with_only_keys[index_of_locale_in_processing].insert(location_to_insert, data[0])locale_list[index_of_locale_in_processing].insert(location_to_insert, data)endend+# Propagate removals+locale_list_with_only_keys.dup.each_with_index do |keys_of_locale_in_processing, index_of_locale_in_processing|+ remove_at = [] of Int32++ keys_of_locale_in_processing.each_with_index do |current_key, current_key_index|+ if !english_locale_keys.includes? current_key+ remove_at << current_key_index+ end+ end++ remove_at.each do |index_to_remove_at|+ locale_list_with_only_keys[index_of_locale_in_processing].delete_at(index_to_remove_at)+ locale_list[index_of_locale_in_processing].delete_at(index_to_remove_at)+ end+end+# Now we convert back to our original format.final_locale_list = [] of Stringlocale_list.each do |locale|