Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/generate_js_licenses.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def create_licence_tr(path, file_name, licence_name, licence_link, source_locati
"<tr>
<td><a href=\\"/#{path}\\">#{file_name}</a></td>
<td><a href=\\"#{licence_link}\\">#{licence_name}</a></td>
<td><a href=\\"#{source_location}\\">\#{translate(locale, "source")}</a></td>
<td><a href=\\"#{source_location}\\">\#{I18n.translate(locale, "source")}</a></td>
</tr>"
HTML

Expand Down
2 changes: 1 addition & 1 deletion src/invidious/channels/channels.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct ChannelVideo
json.field "authorId", self.ucid
json.field "authorUrl", "/channel/#{self.ucid}"
json.field "published", self.published.to_unix
json.field "publishedText", translate(locale, "`x` ago", recode_date(self.published, locale))
json.field "publishedText", I18n.translate(locale, "`x` ago", recode_date(self.published, locale))

json.field "viewCount", self.views
end
Expand Down
2 changes: 1 addition & 1 deletion src/invidious/channels/community.cr
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def extract_channel_community(items, *, ucid, locale, format, thin_mode, is_sing
json.field "contentHtml", content_html

json.field "published", published.to_unix
json.field "publishedText", translate(locale, "`x` ago", recode_date(published, locale))
json.field "publishedText", I18n.translate(locale, "`x` ago", recode_date(published, locale))

json.field "likeCount", like_count
json.field "replyCount", reply_count
Expand Down
2 changes: 1 addition & 1 deletion src/invidious/comments/youtube.cr
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ module Invidious::Comments
end

json.field "published", published.to_unix
json.field "publishedText", translate(locale, "`x` ago", recode_date(published, locale))
json.field "publishedText", I18n.translate(locale, "`x` ago", recode_date(published, locale))
end

if node_replies && !response["commentRepliesContinuation"]?
Expand Down
4 changes: 2 additions & 2 deletions src/invidious/frontend/channel_page.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ module Invidious::Frontend::ChannelPage

if tab == selected_tab
str << "\t<b>"
str << translate(locale, "channel_tab_#{tab_name}_label")
str << I18n.translate(locale, "channel_tab_#{tab_name}_label")
str << "</b>\n"
else
# Video tab doesn't have the last path component
url = tab.videos? ? base_url : "#{base_url}/#{tab_name}"

str << %(\t<a href=") << url << %(">)
str << translate(locale, "channel_tab_#{tab_name}_label")
str << I18n.translate(locale, "channel_tab_#{tab_name}_label")
str << "</a>\n"
end

Expand Down
6 changes: 3 additions & 3 deletions src/invidious/frontend/comments_reddit.cr
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ module Invidious::Frontend::Comments
<p>
<a href="javascript:void(0)" data-onclick="toggle_parent">[ − ]</a>
<b><a href="https://www.reddit.com/user/#{child.author}">#{child.author}</a></b>
#{translate_count(locale, "comments_points_count", child.score, NumberFormatting::Separator)}
<span title="#{child.created_utc.to_s("%a %B %-d %T %Y UTC")}">#{translate(locale, "`x` ago", recode_date(child.created_utc, locale))}</span>
<a href="https://www.reddit.com#{child.permalink}" title="#{translate(locale, "permalink")}">#{translate(locale, "permalink")}</a>
#{I18n.translate_count(locale, "comments_points_count", child.score, I18n::NumberFormatting::Separator)}
<span title="#{child.created_utc.to_s("%a %B %-d %T %Y UTC")}">#{I18n.translate(locale, "`x` ago", recode_date(child.created_utc, locale))}</span>
<a href="https://www.reddit.com#{child.permalink}" title="#{I18n.translate(locale, "permalink")}">#{I18n.translate(locale, "permalink")}</a>
</p>
<div>
#{body_html}
Expand Down
26 changes: 13 additions & 13 deletions src/invidious/frontend/comments_youtube.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ module Invidious::Frontend::Comments
root = comments["comments"].as_a
root.each do |child|
if child["replies"]?
replies_count_text = translate_count(locale,
replies_count_text = I18n.translate_count(locale,
"comments_view_x_replies",
child["replies"]["replyCount"].as_i64 || 0,
NumberFormatting::Separator
I18n::NumberFormatting::Separator
)

replies_html = <<-END_HTML
Expand All @@ -25,10 +25,10 @@ module Invidious::Frontend::Comments
END_HTML
elsif comments["authorId"]? && !comments["singlePost"]?
# for posts we should display a link to the post
replies_count_text = translate_count(locale,
replies_count_text = I18n.translate_count(locale,
"comments_view_x_replies",
child["replyCount"].as_i64 || 0,
NumberFormatting::Separator
I18n::NumberFormatting::Separator
)

replies_html = <<-END_HTML
Expand Down Expand Up @@ -61,7 +61,7 @@ module Invidious::Frontend::Comments
sponsor_icon = String.build do |str|
str << %(<img alt="" )
str << %(src="/ggpht) << URI.parse(child["sponsorIconUrl"].as_s).request_target << "\" "
str << %(title=") << translate(locale, "Channel Sponsor") << "\" "
str << %(title=") << I18n.translate(locale, "Channel Sponsor") << "\" "
str << %(width="16" height="16" />)
end
end
Expand Down Expand Up @@ -110,14 +110,14 @@ module Invidious::Frontend::Comments
when "multiImage"
html << <<-END_HTML
<section class="carousel">
<a class="skip-link" href="#skip-#{child["commentId"]}">#{translate(locale, "carousel_skip")}</a>
<a class="skip-link" href="#skip-#{child["commentId"]}">#{I18n.translate(locale, "carousel_skip")}</a>
<div class="slides">
END_HTML
image_array = attachment["images"].as_a

image_array.each_index do |i|
html << <<-END_HTML
<div class="slides-item slide-#{i + 1}" id="#{child["commentId"]}-slide-#{i + 1}" aria-label="#{translate(locale, "carousel_slide", {"current" => (i + 1).to_s, "total" => image_array.size.to_s})}" tabindex="0">
<div class="slides-item slide-#{i + 1}" id="#{child["commentId"]}-slide-#{i + 1}" aria-label="#{I18n.translate(locale, "carousel_slide", {"current" => (i + 1).to_s, "total" => image_array.size.to_s})}" tabindex="0">
<img loading="lazy" src="/ggpht#{URI.parse(image_array[i][1]["url"].as_s).request_target}" alt="" />
</div>
END_HTML
Expand All @@ -129,7 +129,7 @@ module Invidious::Frontend::Comments
END_HTML
attachment["images"].as_a.each_index do |i|
html << <<-END_HTML
<a class="slider-nav" href="##{child["commentId"]}-slide-#{i + 1}" aria-label="#{translate(locale, "carousel_go_to", (i + 1).to_s)}" tabindex="-1" aria-hidden="true">#{i + 1}</a>
<a class="slider-nav" href="##{child["commentId"]}-slide-#{i + 1}" aria-label="#{I18n.translate(locale, "carousel_go_to", (i + 1).to_s)}" tabindex="-1" aria-hidden="true">#{i + 1}</a>
END_HTML
end
html << <<-END_HTML
Expand All @@ -143,18 +143,18 @@ module Invidious::Frontend::Comments

html << <<-END_HTML
<p>
<span title="#{Time.unix(child["published"].as_i64).to_s(translate(locale, "%A %B %-d, %Y"))}">#{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64), locale))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""}</span>
<span title="#{Time.unix(child["published"].as_i64).to_s(I18n.translate(locale, "%A %B %-d, %Y"))}">#{I18n.translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64), locale))} #{child["isEdited"] == true ? I18n.translate(locale, "(edited)") : ""}</span>
|
END_HTML

if comments["videoId"]?
html << <<-END_HTML
<a rel="noreferrer noopener" href="https://www.youtube.com/watch?v=#{comments["videoId"]}&lc=#{child["commentId"]}" title="#{translate(locale, "YouTube comment permalink")}">[YT]</a>
<a rel="noreferrer noopener" href="https://www.youtube.com/watch?v=#{comments["videoId"]}&lc=#{child["commentId"]}" title="#{I18n.translate(locale, "YouTube comment permalink")}">[YT]</a>
|
END_HTML
elsif comments["authorId"]?
html << <<-END_HTML
<a rel="noreferrer noopener" href="https://www.youtube.com/channel/#{comments["authorId"]}/community?lb=#{child["commentId"]}" title="#{translate(locale, "YouTube comment permalink")}">[YT]</a>
<a rel="noreferrer noopener" href="https://www.youtube.com/channel/#{comments["authorId"]}/community?lb=#{child["commentId"]}" title="#{I18n.translate(locale, "YouTube comment permalink")}">[YT]</a>
|
END_HTML
end
Expand All @@ -172,7 +172,7 @@ module Invidious::Frontend::Comments

html << <<-END_HTML
&nbsp;
<span class="creator-heart-container" title="#{translate(locale, "`x` marked it with a ❤", child["creatorHeart"]["creatorName"].as_s)}">
<span class="creator-heart-container" title="#{I18n.translate(locale, "`x` marked it with a ❤", child["creatorHeart"]["creatorName"].as_s)}">
<span class="creator-heart">
<img loading="lazy" class="creator-heart-background-hearted" src="#{creator_thumbnail}" alt="" />
<span class="creator-heart-small-hearted">
Expand All @@ -197,7 +197,7 @@ module Invidious::Frontend::Comments
<div class="pure-u-1">
<p>
<a href="javascript:void(0)" data-continuation="#{comments["continuation"]}"
data-onclick="get_youtube_replies" data-load-more #{"data-load-replies" if is_replies}>#{translate(locale, "Load more")}</a>
data-onclick="get_youtube_replies" data-load-more #{"data-load-replies" if is_replies}>#{I18n.translate(locale, "Load more")}</a>
</p>
</div>
</div>
Expand Down
18 changes: 9 additions & 9 deletions src/invidious/frontend/pagination.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ module Invidious::Frontend::Pagination
private def first_page(str : String::Builder, locale : String?, url : String)
str << %(<a href=") << url << %(" class="pure-button pure-button-secondary">)

if locale_is_rtl?(locale)
if I18n.locale_is_rtl?(locale)
# Inverted arrow ("first" points to the right)
str << translate(locale, "First page")
str << I18n.translate(locale, "First page")
str << "&nbsp;&nbsp;"
str << %(<i class="icon ion-ios-arrow-forward"></i>)
else
# Regular arrow ("first" points to the left)
str << %(<i class="icon ion-ios-arrow-back"></i>)
str << "&nbsp;&nbsp;"
str << translate(locale, "First page")
str << I18n.translate(locale, "First page")
end

str << "</a>"
Expand All @@ -25,16 +25,16 @@ module Invidious::Frontend::Pagination
# Link
str << %(<a href=") << url << %(" class="pure-button pure-button-secondary">)

if locale_is_rtl?(locale)
if I18n.locale_is_rtl?(locale)
# Inverted arrow ("previous" points to the right)
str << translate(locale, "Previous page")
str << I18n.translate(locale, "Previous page")
str << "&nbsp;&nbsp;"
str << %(<i class="icon ion-ios-arrow-forward"></i>)
else
# Regular arrow ("previous" points to the left)
str << %(<i class="icon ion-ios-arrow-back"></i>)
str << "&nbsp;&nbsp;"
str << translate(locale, "Previous page")
str << I18n.translate(locale, "Previous page")
end

str << "</a>"
Expand All @@ -44,14 +44,14 @@ module Invidious::Frontend::Pagination
# Link
str << %(<a href=") << url << %(" class="pure-button pure-button-secondary">)

if locale_is_rtl?(locale)
if I18n.locale_is_rtl?(locale)
# Inverted arrow ("next" points to the left)
str << %(<i class="icon ion-ios-arrow-back"></i>)
str << "&nbsp;&nbsp;"
str << translate(locale, "Next page")
str << I18n.translate(locale, "Next page")
else
# Regular arrow ("next" points to the right)
str << translate(locale, "Next page")
str << I18n.translate(locale, "Next page")
str << "&nbsp;&nbsp;"
str << %(<i class="icon ion-ios-arrow-forward"></i>)
end
Expand Down
16 changes: 8 additions & 8 deletions src/invidious/frontend/search_filters.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Invidious::Frontend::SearchFilters
return String.build(8000) do |str|
str << "<div id='filters'>\n"
str << "\t<details id='filters-collapse'>"
str << "\t\t<summary>" << translate(locale, "search_filters_title") << "</summary>\n"
str << "\t\t<summary>" << I18n.translate(locale, "search_filters_title") << "</summary>\n"

str << "\t\t<div id='filters-box'><form action='/search' method='get'>\n"

Expand All @@ -25,7 +25,7 @@ module Invidious::Frontend::SearchFilters

str << "\t\t\t<div id='filters-apply'>"
str << "<button type='submit' class=\"pure-button pure-button-primary\">"
str << translate(locale, "search_filters_apply_button")
str << I18n.translate(locale, "search_filters_apply_button")
str << "</button></div>\n"

str << "\t\t</form></div>\n"
Expand All @@ -41,7 +41,7 @@ module Invidious::Frontend::SearchFilters
str << "\t\t\t\t<div class=\"filter-column\"><fieldset>\n"

str << "\t\t\t\t\t<legend><div class=\"filter-name underlined\">"
str << translate(locale, "search_filters_{{name}}_label")
str << I18n.translate(locale, "search_filters_{{name}}_label")
str << "</div></legend>\n"

str << "\t\t\t\t\t<div class=\"filter-options\">\n"
Expand All @@ -62,7 +62,7 @@ module Invidious::Frontend::SearchFilters
str << '>'

str << "<label for='filter-date-{{date}}'>"
str << translate(locale, "search_filters_date_option_{{date}}")
str << I18n.translate(locale, "search_filters_date_option_{{date}}")
str << "</label></div>\n"
{% end %}
end
Expand All @@ -78,7 +78,7 @@ module Invidious::Frontend::SearchFilters
str << '>'

str << "<label for='filter-type-{{type}}'>"
str << translate(locale, "search_filters_type_option_{{type}}")
str << I18n.translate(locale, "search_filters_type_option_{{type}}")
str << "</label></div>\n"
{% end %}
end
Expand All @@ -94,7 +94,7 @@ module Invidious::Frontend::SearchFilters
str << '>'

str << "<label for='filter-duration-{{duration}}'>"
str << translate(locale, "search_filters_duration_option_{{duration}}")
str << I18n.translate(locale, "search_filters_duration_option_{{duration}}")
str << "</label></div>\n"
{% end %}
end
Expand All @@ -111,7 +111,7 @@ module Invidious::Frontend::SearchFilters
str << '>'

str << "<label for='filter-feature-{{feature}}'>"
str << translate(locale, "search_filters_features_option_{{feature}}")
str << I18n.translate(locale, "search_filters_features_option_{{feature}}")
str << "</label></div>\n"
{% end %}
{% end %}
Expand All @@ -128,7 +128,7 @@ module Invidious::Frontend::SearchFilters
str << '>'

str << "<label for='filter-sort-{{sort}}'>"
str << translate(locale, "search_filters_sort_option_{{sort}}")
str << I18n.translate(locale, "search_filters_sort_option_{{sort}}")
str << "</label></div>\n"
{% end %}
end
Expand Down
10 changes: 5 additions & 5 deletions src/invidious/frontend/watch_page.cr
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ module Invidious::Frontend::WatchPage

def download_widget(locale : String, video : Video, video_assets : VideoAssets) : String
if CONFIG.disabled?("downloads")
return "<p id=\"download\">#{translate(locale, "Download is disabled")}</p>"
return "<p id=\"download\">#{I18n.translate(locale, "Download is disabled")}</p>"
end

if CONFIG.dmca_content.includes?(video.id)
return "<p id=\"download\">#{translate(locale, "dmca_content")}</p>"
return "<p id=\"download\">#{I18n.translate(locale, "dmca_content")}</p>"
end

url = "/download"
Expand All @@ -49,7 +49,7 @@ module Invidious::Frontend::WatchPage
str << "\t<div class=\"pure-control-group\">\n"

str << "\t\t<label for='download_widget'>"
str << translate(locale, "Download as: ")
str << I18n.translate(locale, "Download as: ")
str << "</label>\n"

str << "\t\t<select name='download_widget' id='download_widget'>\n"
Expand Down Expand Up @@ -98,7 +98,7 @@ module Invidious::Frontend::WatchPage
value = {"label": caption.name, "ext": "#{caption.language_code}.vtt"}.to_json

str << "\t\t\t<option value='" << value << "'>"
str << translate(locale, "download_subtitles", translate(locale, caption.name))
str << I18n.translate(locale, "download_subtitles", I18n.translate(locale, caption.name))
str << "</option>\n"
end

Expand All @@ -108,7 +108,7 @@ module Invidious::Frontend::WatchPage
str << "\t</div>\n"

str << "\t<button type=\"submit\" class=\"pure-button pure-button-primary\">\n"
str << "\t\t<b>" << translate(locale, "Download") << "</b>\n"
str << "\t\t<b>" << I18n.translate(locale, "Download") << "</b>\n"
str << "\t</button>\n"

str << "</form>\n"
Expand Down
24 changes: 12 additions & 12 deletions src/invidious/helpers/errors.cr
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce

error_message = <<-END_HTML
<div class="error_message">
<h2>#{translate(locale, "crash_page_you_found_a_bug")}</h2>
<h2>#{I18n.translate(locale, "crash_page_you_found_a_bug")}</h2>
<br/><br/>

<p><b>#{translate(locale, "crash_page_before_reporting")}</b></p>
<p><b>#{I18n.translate(locale, "crash_page_before_reporting")}</b></p>
<ul>
<li>#{translate(locale, "crash_page_refresh", env.request.resource)}</li>
<li>#{translate(locale, "crash_page_switch_instance", url_switch)}</li>
<li>#{translate(locale, "crash_page_read_the_faq", url_faq)}</li>
<li>#{translate(locale, "crash_page_search_issue", url_search_issues)}</li>
<li>#{I18n.translate(locale, "crash_page_refresh", env.request.resource)}</li>
<li>#{I18n.translate(locale, "crash_page_switch_instance", url_switch)}</li>
<li>#{I18n.translate(locale, "crash_page_read_the_faq", url_faq)}</li>
<li>#{I18n.translate(locale, "crash_page_search_issue", url_search_issues)}</li>
</ul>

<br/>
<p>#{translate(locale, "crash_page_report_issue", url_new_issue)}</p>
<p>#{I18n.translate(locale, "crash_page_report_issue", url_new_issue)}</p>

<!-- TODO: Add a "copy to clipboard" button -->
<pre class="error-issue-template">#{issue_template}</pre>
Expand All @@ -95,7 +95,7 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, mess

locale = env.get("preferences").as(Preferences).locale

error_message = translate(locale, message)
error_message = I18n.translate(locale, message)
next_steps = error_redirect_helper(env)

return templated "error"
Expand Down Expand Up @@ -186,10 +186,10 @@ def error_redirect_helper(env : HTTP::Server::Context)

if request_path.starts_with?("/search") || request_path.starts_with?("/watch") ||
request_path.starts_with?("/channel") || request_path.starts_with?("/playlist?list=PL")
next_steps_text = translate(locale, "next_steps_error_message")
refresh = translate(locale, "next_steps_error_message_refresh")
go_to_youtube = translate(locale, "next_steps_error_message_go_to_youtube")
switch_instance = translate(locale, "Switch Invidious Instance")
next_steps_text = I18n.translate(locale, "next_steps_error_message")
refresh = I18n.translate(locale, "next_steps_error_message_refresh")
go_to_youtube = I18n.translate(locale, "next_steps_error_message_go_to_youtube")
switch_instance = I18n.translate(locale, "Switch Invidious Instance")

return <<-END_HTML
<p style="margin-bottom: 4px;">#{next_steps_text}</p>
Expand Down
Loading