FIX: Localize text in github oneboxes (#25327)
This commit is contained in:
parent
f4e51e0789
commit
d401502834
|
@ -5235,6 +5235,22 @@ en:
|
||||||
onebox:
|
onebox:
|
||||||
discourse:
|
discourse:
|
||||||
user_joined_community: "Joined %{date}"
|
user_joined_community: "Joined %{date}"
|
||||||
|
gitlab:
|
||||||
|
truncated_file: "This file has been truncated."
|
||||||
|
show_original: "show original"
|
||||||
|
github:
|
||||||
|
binary_file: "This file is binary."
|
||||||
|
truncated_file: "This file has been truncated."
|
||||||
|
show_original: "show original"
|
||||||
|
requires_iframe: "Viewer requires iframe."
|
||||||
|
committed: "committed"
|
||||||
|
more_than_three_files: "There are more than three files."
|
||||||
|
opened: "opened"
|
||||||
|
closed: "closed"
|
||||||
|
commit_by: "Commit by"
|
||||||
|
comment_by: "Comment by"
|
||||||
|
review_by: "Review by"
|
||||||
|
pr_summary: "%{commits} commits changed %{changed_files} files with %{additions} additions and %{deletions} deletions"
|
||||||
|
|
||||||
discourse_push_notifications:
|
discourse_push_notifications:
|
||||||
popup:
|
popup:
|
||||||
|
|
|
@ -15,6 +15,15 @@ module Onebox
|
||||||
|
|
||||||
include Onebox::Mixins::GitBlobOnebox
|
include Onebox::Mixins::GitBlobOnebox
|
||||||
|
|
||||||
|
def i18n
|
||||||
|
{
|
||||||
|
binary_file: I18n.t("onebox.github.binary_file"),
|
||||||
|
truncated_file: I18n.t("onebox.github.truncated_file"),
|
||||||
|
show_original: I18n.t("onebox.github.show_original"),
|
||||||
|
requires_iframe: I18n.t("onebox.github.requires_iframe"),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def raw_regexp
|
def raw_regexp
|
||||||
%r{github\.com/(?<user>[^/]+)/(?<repo>[^/]+)/blob/(?<sha1>[^/]+)/(?<file>[^#]+)(#(L(?<from>[^-]*)(-L(?<to>.*))?))?}mi
|
%r{github\.com/(?<user>[^/]+)/(?<repo>[^/]+)/blob/(?<sha1>[^/]+)/(?<file>[^#]+)(#(L(?<from>[^-]*)(-L(?<to>.*))?))?}mi
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,6 +47,7 @@ module Onebox
|
||||||
result["link"] = link
|
result["link"] = link
|
||||||
ulink = URI(link)
|
ulink = URI(link)
|
||||||
result["domain"] = "#{ulink.host}/#{ulink.path.split("/")[1]}/#{ulink.path.split("/")[2]}"
|
result["domain"] = "#{ulink.host}/#{ulink.path.split("/")[1]}/#{ulink.path.split("/")[2]}"
|
||||||
|
result["i18n"] = { committed: I18n.t("onebox.github.committed") }
|
||||||
|
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,6 +24,15 @@ module Onebox
|
||||||
link: link,
|
link: link,
|
||||||
gist_files: gist_files.take(MAX_FILES),
|
gist_files: gist_files.take(MAX_FILES),
|
||||||
truncated_files?: truncated_files?,
|
truncated_files?: truncated_files?,
|
||||||
|
i18n: i18n,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def i18n
|
||||||
|
{
|
||||||
|
truncated_file: I18n.t("onebox.github.truncated_file"),
|
||||||
|
more_than_three_files: I18n.t("onebox.github.more_than_three_files"),
|
||||||
|
show_original: I18n.t("onebox.github.show_original"),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@ module Onebox
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def i18n
|
||||||
|
{ opened: I18n.t("onebox.github.opened"), closed: I18n.t("onebox.github.closed") }
|
||||||
|
end
|
||||||
|
|
||||||
def data
|
def data
|
||||||
created_at = Time.parse(raw["created_at"])
|
created_at = Time.parse(raw["created_at"])
|
||||||
closed_at = Time.parse(raw["closed_at"]) if raw["closed_at"]
|
closed_at = Time.parse(raw["closed_at"]) if raw["closed_at"]
|
||||||
|
@ -54,6 +58,7 @@ module Onebox
|
||||||
closed_by: raw["closed_by"],
|
closed_by: raw["closed_by"],
|
||||||
avatar: "https://avatars1.githubusercontent.com/u/#{raw["user"]["id"]}?v=2&s=96",
|
avatar: "https://avatars1.githubusercontent.com/u/#{raw["user"]["id"]}?v=2&s=96",
|
||||||
domain: "#{ulink.host}/#{ulink.path.split("/")[1]}/#{ulink.path.split("/")[2]}",
|
domain: "#{ulink.host}/#{ulink.path.split("/")[1]}/#{ulink.path.split("/")[2]}",
|
||||||
|
i18n: i18n,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,10 +50,29 @@ module Onebox
|
||||||
else
|
else
|
||||||
result["pr"] = true
|
result["pr"] = true
|
||||||
end
|
end
|
||||||
|
result["i18n"] = i18n
|
||||||
|
result["i18n"]["pr_summary"] = I18n.t(
|
||||||
|
"onebox.github.pr_summary",
|
||||||
|
{
|
||||||
|
commits: result["commits"],
|
||||||
|
changed_files: result["changed_files"],
|
||||||
|
additions: result["additions"],
|
||||||
|
deletions: result["deletions"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def i18n
|
||||||
|
{
|
||||||
|
opened: I18n.t("onebox.github.opened"),
|
||||||
|
commit_by: I18n.t("onebox.github.commit_by"),
|
||||||
|
comment_by: I18n.t("onebox.github.comment_by"),
|
||||||
|
review_by: I18n.t("onebox.github.review_by"),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def load_commit(link)
|
def load_commit(link)
|
||||||
if commit_match = link.match(%r{commits/(\h+)})
|
if commit_match = link.match(%r{commits/(\h+)})
|
||||||
load_json(
|
load_json(
|
||||||
|
|
|
@ -15,6 +15,13 @@ module Onebox
|
||||||
|
|
||||||
include Onebox::Mixins::GitBlobOnebox
|
include Onebox::Mixins::GitBlobOnebox
|
||||||
|
|
||||||
|
def i18n
|
||||||
|
{
|
||||||
|
truncated_file: I18n.t("onebox.gitlab.truncated_file"),
|
||||||
|
show_original: I18n.t("onebox.gitlab.show_original"),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def raw_regexp
|
def raw_regexp
|
||||||
%r{gitlab\.com/(?<user>[^/]+)/(?<repo>[^/]+)/blob/(?<sha1>[^/]+)/(?<file>[^#]+)(#(L(?<from>[^-]*)(-L(?<to>.*))?))?}mi
|
%r{gitlab\.com/(?<user>[^/]+)/(?<repo>[^/]+)/blob/(?<sha1>[^/]+)/(?<file>[^#]+)(#(L(?<from>[^-]*)(-L(?<to>.*))?))?}mi
|
||||||
end
|
end
|
||||||
|
|
|
@ -220,6 +220,7 @@ module Onebox
|
||||||
@data ||= {
|
@data ||= {
|
||||||
title: title,
|
title: title,
|
||||||
link: link,
|
link: link,
|
||||||
|
i18n: i18n,
|
||||||
# IMPORTANT NOTE: All of the other class variables are populated
|
# IMPORTANT NOTE: All of the other class variables are populated
|
||||||
# as *side effects* of the `raw` method! They must all appear
|
# as *side effects* of the `raw` method! They must all appear
|
||||||
# AFTER the call to `raw`! Don't get bitten by this like I did!
|
# AFTER the call to `raw`! Don't get bitten by this like I did!
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{{^has_lines}}
|
{{^has_lines}}
|
||||||
{{#model_file}}
|
{{#model_file}}
|
||||||
<iframe class="render-viewer" width="{{width}}" height="{{height}}" src="{{content}}" sandbox="allow-scripts allow-same-origin allow-top-navigation ">
|
<iframe class="render-viewer" width="{{width}}" height="{{height}}" src="{{content}}" sandbox="allow-scripts allow-same-origin allow-top-navigation ">
|
||||||
Viewer requires iframe.
|
{{i18n.requires_iframe}}
|
||||||
</iframe>
|
</iframe>
|
||||||
{{/model_file}}
|
{{/model_file}}
|
||||||
|
|
||||||
|
@ -51,9 +51,9 @@
|
||||||
{{/binary}}
|
{{/binary}}
|
||||||
|
|
||||||
{{#binary}}
|
{{#binary}}
|
||||||
This file is binary. <a href="{{link}}" target="_blank" rel="noopener">show original</a>
|
{{i18n.binary_file}} <a href="{{link}}" target="_blank" rel="noopener">{{i18n.show_original}}</a>
|
||||||
{{/binary}}
|
{{/binary}}
|
||||||
|
|
||||||
{{#truncated}}
|
{{#truncated}}
|
||||||
This file has been truncated. <a href="{{link}}" target="_blank" rel="noopener">show original</a>
|
{{i18n.truncated_file}} <a href="{{link}}" target="_blank" rel="noopener">{{i18n.show_original}}</a>
|
||||||
{{/truncated}}
|
{{/truncated}}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<div class="github-info">
|
<div class="github-info">
|
||||||
<div class="date">
|
<div class="date">
|
||||||
committed <span class="discourse-local-date" data-format="ll" data-date="{{committed_at_date}}" data-time="{{committed_at_time}}" data-timezone="UTC">{{committed_at}}</span>
|
{{i18n.committed}} <span class="discourse-local-date" data-format="ll" data-date="{{committed_at_date}}" data-time="{{committed_at_time}}" data-timezone="UTC">{{committed_at}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="user">
|
<div class="user">
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
<h5>{{filename}}</h5>
|
<h5>{{filename}}</h5>
|
||||||
<pre><code class="{{language}}">{{content}}</code></pre>
|
<pre><code class="{{language}}">{{content}}</code></pre>
|
||||||
{{#truncated?}}
|
{{#truncated?}}
|
||||||
This file has been truncated. <a href="{{link}}" target="_blank" rel="noopener">show original</a>
|
{{i18n.truncated_file}} <a href="{{link}}" target="_blank" rel="noopener">{{i18n.show_original}}</a>
|
||||||
{{/truncated?}}
|
{{/truncated?}}
|
||||||
{{/gist_files}}
|
{{/gist_files}}
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{{#truncated_files?}}
|
{{#truncated_files?}}
|
||||||
There are more than three files. <a href="{{link}}" target="_blank" rel="noopener">show original</a>
|
{{i18n.more_than_three_files}} <a href="{{link}}" target="_blank" rel="noopener">{{i18n.show_original}}</a>
|
||||||
{{/truncated_files?}}
|
{{/truncated_files?}}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
<div class="github-info">
|
<div class="github-info">
|
||||||
<div class="date">
|
<div class="date">
|
||||||
opened <span class="discourse-local-date" data-format="ll" data-date="{{created_at_date}}" data-time="{{created_at_time}}" data-timezone="UTC">{{created_at}}</span>
|
{{i18n.opened}} <span class="discourse-local-date" data-format="ll" data-date="{{created_at_date}}" data-time="{{created_at_time}}" data-timezone="UTC">{{created_at}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#closed_at}}
|
{{#closed_at}}
|
||||||
<div class="date">
|
<div class="date">
|
||||||
closed <span class="discourse-local-date" data-format="ll" data-date="{{closed_at_date}}" data-time="{{closed_at_time}}" data-timezone="UTC">{{closed_at}}</span>
|
{{i18n.closed}} <span class="discourse-local-date" data-format="ll" data-date="{{closed_at_date}}" data-time="{{closed_at_time}}" data-timezone="UTC">{{closed_at}}</span>
|
||||||
</div>
|
</div>
|
||||||
{{/closed_at}}
|
{{/closed_at}}
|
||||||
|
|
||||||
|
|
|
@ -31,38 +31,32 @@
|
||||||
|
|
||||||
<div class="github-info">
|
<div class="github-info">
|
||||||
<span>
|
<span>
|
||||||
Commit by
|
{{i18n.commit_by}}
|
||||||
<a href="{{author.html_url}}" target="_blank" rel="noopener">
|
<a href="{{author.html_url}}" target="_blank" rel="noopener">
|
||||||
<img alt="{{author.login}}" src="{{author.avatar_url}}" class="onebox-avatar-inline" width="20" height="20">
|
<img alt="{{author.login}}" src="{{author.avatar_url}}" class="onebox-avatar-inline" width="20" height="20">
|
||||||
{{author.login}}
|
{{author.login}}
|
||||||
</a>
|
</a> - <a href="{{link}}" target="_blank" rel="noopener">{{title}}</a>
|
||||||
in
|
|
||||||
<a href="{{link}}" target="_blank" rel="noopener">{{title}}</a>
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{{/commit}}
|
{{/commit}}
|
||||||
|
|
||||||
{{#comment}}
|
{{#comment}}
|
||||||
<h4>
|
<h4>
|
||||||
Comment by
|
{{i18n.comment_by}}
|
||||||
<a href="{{user.html_url}}" target="_blank" rel="noopener">
|
<a href="{{user.html_url}}" target="_blank" rel="noopener">
|
||||||
<img alt="{{user.login}}" src="{{user.avatar_url}}" class="onebox-avatar-inline" width="20" height="20">
|
<img alt="{{user.login}}" src="{{user.avatar_url}}" class="onebox-avatar-inline" width="20" height="20">
|
||||||
{{user.login}}
|
{{user.login}}
|
||||||
</a>
|
</a> - <a href="{{link}}" target="_blank" rel="noopener">{{title}}</a>
|
||||||
to
|
|
||||||
<a href="{{link}}" target="_blank" rel="noopener">{{title}}</a>
|
|
||||||
</h4>
|
</h4>
|
||||||
{{/comment}}
|
{{/comment}}
|
||||||
|
|
||||||
{{#discussion}}
|
{{#discussion}}
|
||||||
<h4>
|
<h4>
|
||||||
Review by
|
{{i18n.review_by}}
|
||||||
<a href="{{user.html_url}}" target="_blank" rel="noopener">
|
<a href="{{user.html_url}}" target="_blank" rel="noopener">
|
||||||
<img alt="{{user.login}}" src="{{user.avatar_url}}" class="onebox-avatar-inline" width="20" height="20">
|
<img alt="{{user.login}}" src="{{user.avatar_url}}" class="onebox-avatar-inline" width="20" height="20">
|
||||||
{{user.login}}
|
{{user.login}}
|
||||||
</a>
|
</a> - <a href="{{link}}" target="_blank" rel="noopener">{{title}}</a>
|
||||||
in
|
|
||||||
<a href="{{link}}" target="_blank" rel="noopener">{{title}}</a>
|
|
||||||
</h4>
|
</h4>
|
||||||
{{/discussion}}
|
{{/discussion}}
|
||||||
|
|
||||||
|
@ -79,7 +73,7 @@
|
||||||
{{#pr}}
|
{{#pr}}
|
||||||
<div class="github-info">
|
<div class="github-info">
|
||||||
<div class="date">
|
<div class="date">
|
||||||
opened <span class="discourse-local-date" data-format="ll" data-date="{{created_at_date}}" data-time="{{created_at_time}}" data-timezone="UTC">{{created_at}}</span>
|
{{i18n.opened}} <span class="discourse-local-date" data-format="ll" data-date="{{created_at_date}}" data-time="{{created_at_time}}" data-timezone="UTC">{{created_at}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="user">
|
<div class="user">
|
||||||
|
@ -89,7 +83,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="lines" title="{{commits}} commits changed {{changed_files}} files with {{additions}} additions and {{deletions}} deletions">
|
<div class="lines" title="{{i18n.pr_summary}}">
|
||||||
<a href="{{html_url}}/files" target="_blank" rel="noopener">
|
<a href="{{html_url}}/files" target="_blank" rel="noopener">
|
||||||
<span class="added">+{{additions}}</span>
|
<span class="added">+{{additions}}</span>
|
||||||
<span class="removed">-{{deletions}}</span>
|
<span class="removed">-{{deletions}}</span>
|
||||||
|
|
|
@ -17,5 +17,5 @@
|
||||||
{{/has_lines}}
|
{{/has_lines}}
|
||||||
|
|
||||||
{{#truncated}}
|
{{#truncated}}
|
||||||
This file has been truncated. <a href="{{link}}" target="_blank" rel="noopener">show original</a>
|
{{i18n.truncated_file}} <a href="{{link}}" target="_blank" rel="noopener">{{i18n.show_original}}</a>
|
||||||
{{/truncated}}
|
{{/truncated}}
|
||||||
|
|
Loading…
Reference in New Issue