Skip to content

Commit 2b498d9

Browse files
author
Tim Bannister
committed
Make tooltip localizable
Allow localizations to customize the tooltip for copying code samples to the clipboard.
1 parent 9e128e3 commit 2b498d9

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

data/i18n/en/en.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ other = "YouTube"
6868
[conjunction_1]
6969
other = "and"
7070

71+
[copy_sample_to_clipboard]
72+
other = "Copy {{ .filename }} to clipboard"
73+
7174
[cve_id]
7275
other = "CVE ID"
7376

layouts/shortcodes/code.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
<div class="copy-code-icon">
2323
{{ with $ghlink }}<a href="{{ . }}" download="{{ $file }}">{{ end }}<code>{{ $file }}</code>
2424
{{ if $ghlink }}</a>{{ end }}
25+
{{- $copyTitle := T "copy_sample_to_clipboard" (dict "filename" $file) -}}
2526
{{- with resources.Get "images/copycode.svg" -}}
26-
<img src="{{ .RelPermalink }}" class="icon-copycode" onclick="copyCode('{{ $file | anchorize }}')" title="Copy {{ $file }} to clipboard"></img>
27+
<img src="{{ .RelPermalink }}" class="icon-copycode" onclick="copyCode('{{ $file | anchorize }}')" title="{{ $copyTitle }}"></img>
2728
{{- end -}}
2829
</div>
2930
<div class="includecode" id="{{ $file | anchorize }}">

layouts/shortcodes/code_sample.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
<div class="copy-code-icon">
2323
{{ with $ghlink }}<a href="{{ . }}" download="{{ $file }}">{{ end }}<code>{{ $file }}</code>
2424
{{ if $ghlink }}</a>{{ end }}
25+
{{- $copyTitle := T "copy_sample_to_clipboard" (dict "filename" $file) -}}
2526
{{- with resources.Get "images/copycode.svg" -}}
26-
<img src="{{ .RelPermalink }}" class="icon-copycode" onclick="copyCode('{{ $file | anchorize }}')" title="Copy {{ $file }} to clipboard"></img>
27+
<img src="{{ .RelPermalink }}" class="icon-copycode" onclick="copyCode('{{ $file | anchorize }}')" title="{{ $copyTitle }}"></img>
2728
{{- end -}}
2829
</div>
2930
<div class="includecode" id="{{ $file | anchorize }}">

layouts/shortcodes/codenew.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
<div class="copy-code-icon">
2323
{{ with $ghlink }}<a href="{{ . }}" download="{{ $file }}">{{ end }}<code>{{ $file }}</code>
2424
{{ if $ghlink }}</a>{{ end }}
25+
{{- $copyTitle := T "copy_sample_to_clipboard" (dict "filename" $file) -}}
2526
{{- with resources.Get "images/copycode.svg" -}}
26-
<img src="{{ .RelPermalink }}" class="icon-copycode" onclick="copyCode('{{ $file | anchorize }}')" title="Copy {{ $file }} to clipboard"></img>
27+
<img src="{{ .RelPermalink }}" class="icon-copycode" onclick="copyCode('{{ $file | anchorize }}')" title="{{ $copyTitle }}"></img>
2728
{{- end -}}
2829
</div>
2930
<div class="includecode" id="{{ $file | anchorize }}">

0 commit comments

Comments
 (0)