forked from midou/invidious
Merge pull request #2529 from DmitrySandalov/master
Feature Request: Localization for trending iv-org#331
This commit is contained in:
commit
2b81a82620
@ -504,6 +504,21 @@ default_user_preferences:
|
|||||||
##
|
##
|
||||||
#locale: en-US
|
#locale: en-US
|
||||||
|
|
||||||
|
##
|
||||||
|
## Default geographical location for content.
|
||||||
|
##
|
||||||
|
## Accepted values:
|
||||||
|
## AE, AR, AT, AU, AZ, BA, BD, BE, BG, BH, BO, BR, BY, CA, CH, CL, CO, CR,
|
||||||
|
## CY, CZ, DE, DK, DO, DZ, EC, EE, EG, ES, FI, FR, GB, GE, GH, GR, GT, HK,
|
||||||
|
## HN, HR, HU, ID, IE, IL, IN, IQ, IS, IT, JM, JO, JP, KE, KR, KW, KZ, LB,
|
||||||
|
## LI, LK, LT, LU, LV, LY, MA, ME, MK, MT, MX, MY, NG, NI, NL, NO, NP, NZ,
|
||||||
|
## OM, PA, PE, PG, PH, PK, PL, PR, PT, PY, QA, RO, RS, RU, SA, SE, SG, SI,
|
||||||
|
## SK, SN, SV, TH, TN, TR, TW, TZ, UA, UG, US, UY, VE, VN, YE, ZA, ZW
|
||||||
|
##
|
||||||
|
## Default: US
|
||||||
|
##
|
||||||
|
#region: US
|
||||||
|
|
||||||
##
|
##
|
||||||
## Top 3 prefered languages for video captions.
|
## Top 3 prefered languages for video captions.
|
||||||
##
|
##
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
"preferences_extend_desc_label": "Automatically extend video description: ",
|
"preferences_extend_desc_label": "Automatically extend video description: ",
|
||||||
"preferences_vr_mode_label": "Interactive 360 degree videos: ",
|
"preferences_vr_mode_label": "Interactive 360 degree videos: ",
|
||||||
"preferences_category_visual": "Visual preferences",
|
"preferences_category_visual": "Visual preferences",
|
||||||
|
"preferences_region_label": "Content country: ",
|
||||||
"preferences_player_style_label": "Player style: ",
|
"preferences_player_style_label": "Player style: ",
|
||||||
"Dark mode: ": "Dark mode: ",
|
"Dark mode: ": "Dark mode: ",
|
||||||
"preferences_dark_mode_label": "Theme: ",
|
"preferences_dark_mode_label": "Theme: ",
|
||||||
|
@ -31,6 +31,7 @@ struct ConfigPreferences
|
|||||||
property default_home : String? = "Popular"
|
property default_home : String? = "Popular"
|
||||||
property feed_menu : Array(String) = ["Popular", "Trending", "Subscriptions", "Playlists"]
|
property feed_menu : Array(String) = ["Popular", "Trending", "Subscriptions", "Playlists"]
|
||||||
property automatic_instance_redirect : Bool = false
|
property automatic_instance_redirect : Bool = false
|
||||||
|
property region : String = "US"
|
||||||
property related_videos : Bool = true
|
property related_videos : Bool = true
|
||||||
property sort : String = "published"
|
property sort : String = "published"
|
||||||
property speed : Float32 = 1.0_f32
|
property speed : Float32 = 1.0_f32
|
||||||
|
@ -41,6 +41,18 @@ LOCALES = {
|
|||||||
"zh-TW" => load_locale("zh-TW"), # Chinese (Traditional)
|
"zh-TW" => load_locale("zh-TW"), # Chinese (Traditional)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CONTENT_REGIONS = {
|
||||||
|
"AE", "AR", "AT", "AU", "AZ", "BA", "BD", "BE", "BG", "BH", "BO", "BR", "BY",
|
||||||
|
"CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "DZ", "EC", "EE",
|
||||||
|
"EG", "ES", "FI", "FR", "GB", "GE", "GH", "GR", "GT", "HK", "HN", "HR", "HU",
|
||||||
|
"ID", "IE", "IL", "IN", "IQ", "IS", "IT", "JM", "JO", "JP", "KE", "KR", "KW",
|
||||||
|
"KZ", "LB", "LI", "LK", "LT", "LU", "LV", "LY", "MA", "ME", "MK", "MT", "MX",
|
||||||
|
"MY", "NG", "NI", "NL", "NO", "NP", "NZ", "OM", "PA", "PE", "PG", "PH", "PK",
|
||||||
|
"PL", "PR", "PT", "PY", "QA", "RO", "RS", "RU", "SA", "SE", "SG", "SI", "SK",
|
||||||
|
"SN", "SV", "TH", "TN", "TR", "TW", "TZ", "UA", "UG", "US", "UY", "VE", "VN",
|
||||||
|
"YE", "ZA", "ZW",
|
||||||
|
}
|
||||||
|
|
||||||
def load_locale(name)
|
def load_locale(name)
|
||||||
return JSON.parse(File.read("locales/#{name}.json")).as_h
|
return JSON.parse(File.read("locales/#{name}.json")).as_h
|
||||||
end
|
end
|
||||||
|
@ -48,7 +48,7 @@ module Invidious::Routes::Feeds
|
|||||||
trending_type ||= "Default"
|
trending_type ||= "Default"
|
||||||
|
|
||||||
region = env.params.query["region"]?
|
region = env.params.query["region"]?
|
||||||
region ||= "US"
|
region ||= env.get("preferences").as(Preferences).region
|
||||||
|
|
||||||
begin
|
begin
|
||||||
trending, plid = fetch_trending(trending_type, region, locale)
|
trending, plid = fetch_trending(trending_type, region, locale)
|
||||||
|
@ -102,6 +102,8 @@ module Invidious::Routes::PreferencesRoute
|
|||||||
automatic_instance_redirect ||= "off"
|
automatic_instance_redirect ||= "off"
|
||||||
automatic_instance_redirect = automatic_instance_redirect == "on"
|
automatic_instance_redirect = automatic_instance_redirect == "on"
|
||||||
|
|
||||||
|
region = env.params.body["region"]?.try &.as(String)
|
||||||
|
|
||||||
locale = env.params.body["locale"]?.try &.as(String)
|
locale = env.params.body["locale"]?.try &.as(String)
|
||||||
locale ||= CONFIG.default_user_preferences.locale
|
locale ||= CONFIG.default_user_preferences.locale
|
||||||
|
|
||||||
@ -152,6 +154,7 @@ module Invidious::Routes::PreferencesRoute
|
|||||||
default_home: default_home,
|
default_home: default_home,
|
||||||
feed_menu: feed_menu,
|
feed_menu: feed_menu,
|
||||||
automatic_instance_redirect: automatic_instance_redirect,
|
automatic_instance_redirect: automatic_instance_redirect,
|
||||||
|
region: region,
|
||||||
related_videos: related_videos,
|
related_videos: related_videos,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
speed: speed,
|
speed: speed,
|
||||||
|
@ -28,6 +28,7 @@ struct Preferences
|
|||||||
|
|
||||||
@[JSON::Field(converter: Preferences::ProcessString)]
|
@[JSON::Field(converter: Preferences::ProcessString)]
|
||||||
property locale : String = CONFIG.default_user_preferences.locale
|
property locale : String = CONFIG.default_user_preferences.locale
|
||||||
|
property region : String? = CONFIG.default_user_preferences.region
|
||||||
|
|
||||||
@[JSON::Field(converter: Preferences::ClampInt)]
|
@[JSON::Field(converter: Preferences::ClampInt)]
|
||||||
property max_results : Int32 = CONFIG.default_user_preferences.max_results
|
property max_results : Int32 = CONFIG.default_user_preferences.max_results
|
||||||
|
@ -127,6 +127,15 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="region"><%= translate(locale, "preferences_region_label") %></label>
|
||||||
|
<select name="region" id="region">
|
||||||
|
<% CONTENT_REGIONS.each do |option| %>
|
||||||
|
<option value="<%= option %>" <% if preferences.region == option %> selected <% end %>><%= option %></option>
|
||||||
|
<% end %>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="player_style"><%= translate(locale, "preferences_player_style_label") %></label>
|
<label for="player_style"><%= translate(locale, "preferences_player_style_label") %></label>
|
||||||
<select name="player_style" id="player_style">
|
<select name="player_style" id="player_style">
|
||||||
|
Loading…
Reference in New Issue
Block a user