mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-23 05:33:07 +05:30
Add ability to propagate locale removals
This commit is contained in:
parent
4eb3de7b4e
commit
d432732959
@ -20,7 +20,7 @@ end
|
|||||||
# Invidious currently has some unloaded localization files. We shouldn't need to propagate new keys onto those.
|
# 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.
|
# We'll also remove the reference locale (english) from the list to process.
|
||||||
loaded_locales = LOCALES.keys.select! { |key| key != "en-US" }
|
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.
|
# 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
|
# 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_locale
|
locale_list_with_only_keys << keys_only_locale
|
||||||
end
|
end
|
||||||
|
|
||||||
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)
|
insert_at = {} of Int32 => Tuple(String, JSON::Any | String)
|
||||||
|
|
||||||
LOCALES["en-US"].each_with_index do |ref_locale_data, ref_locale_key_index|
|
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, ind
|
|||||||
end
|
end
|
||||||
|
|
||||||
insert_at.each do |location_to_insert, data|
|
insert_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)
|
locale_list[index_of_locale_in_processing].insert(location_to_insert, data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 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.
|
# Now we convert back to our original format.
|
||||||
final_locale_list = [] of String
|
final_locale_list = [] of String
|
||||||
locale_list.each do |locale|
|
locale_list.each do |locale|
|
||||||
|
Loading…
Reference in New Issue
Block a user