Skip to content

Commit

Permalink
Make tooltip localizable
Browse files Browse the repository at this point in the history
Allow localizations to customize the tooltip for copying code samples to
the clipboard.
  • Loading branch information
sftim committed May 14, 2024
1 parent 9e128e3 commit 2b498d9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions data/i18n/en/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ other = "YouTube"
[conjunction_1]
other = "and"

[copy_sample_to_clipboard]
other = "Copy {{ .filename }} to clipboard"

[cve_id]
other = "CVE ID"

Expand Down
3 changes: 2 additions & 1 deletion layouts/shortcodes/code.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
<div class="copy-code-icon">
{{ with $ghlink }}<a href="{{ . }}" download="{{ $file }}">{{ end }}<code>{{ $file }}</code>
{{ if $ghlink }}</a>{{ end }}
{{- $copyTitle := T "copy_sample_to_clipboard" (dict "filename" $file) -}}
{{- with resources.Get "images/copycode.svg" -}}
<img src="{{ .RelPermalink }}" class="icon-copycode" onclick="copyCode('{{ $file | anchorize }}')" title="Copy {{ $file }} to clipboard"></img>
<img src="{{ .RelPermalink }}" class="icon-copycode" onclick="copyCode('{{ $file | anchorize }}')" title="{{ $copyTitle }}"></img>
{{- end -}}
</div>
<div class="includecode" id="{{ $file | anchorize }}">
Expand Down
3 changes: 2 additions & 1 deletion layouts/shortcodes/code_sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
<div class="copy-code-icon">
{{ with $ghlink }}<a href="{{ . }}" download="{{ $file }}">{{ end }}<code>{{ $file }}</code>
{{ if $ghlink }}</a>{{ end }}
{{- $copyTitle := T "copy_sample_to_clipboard" (dict "filename" $file) -}}
{{- with resources.Get "images/copycode.svg" -}}
<img src="{{ .RelPermalink }}" class="icon-copycode" onclick="copyCode('{{ $file | anchorize }}')" title="Copy {{ $file }} to clipboard"></img>
<img src="{{ .RelPermalink }}" class="icon-copycode" onclick="copyCode('{{ $file | anchorize }}')" title="{{ $copyTitle }}"></img>
{{- end -}}
</div>
<div class="includecode" id="{{ $file | anchorize }}">
Expand Down
3 changes: 2 additions & 1 deletion layouts/shortcodes/codenew.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
<div class="copy-code-icon">
{{ with $ghlink }}<a href="{{ . }}" download="{{ $file }}">{{ end }}<code>{{ $file }}</code>
{{ if $ghlink }}</a>{{ end }}
{{- $copyTitle := T "copy_sample_to_clipboard" (dict "filename" $file) -}}
{{- with resources.Get "images/copycode.svg" -}}
<img src="{{ .RelPermalink }}" class="icon-copycode" onclick="copyCode('{{ $file | anchorize }}')" title="Copy {{ $file }} to clipboard"></img>
<img src="{{ .RelPermalink }}" class="icon-copycode" onclick="copyCode('{{ $file | anchorize }}')" title="{{ $copyTitle }}"></img>
{{- end -}}
</div>
<div class="includecode" id="{{ $file | anchorize }}">
Expand Down

0 comments on commit 2b498d9

Please sign in to comment.