Skip to content

Commit ad61f00

Browse files
bitschmidtyjnewbery
authored andcommitted
Template: update translations navigation bar
1 parent 55d8add commit ad61f00

File tree

8 files changed

+31
-30
lines changed

8 files changed

+31
-30
lines changed

_config.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,23 @@ defaults:
5151
values:
5252
image: https://bitcoinops.org/img/logos/optech-notext.png
5353
breadcrumbs: true
54+
localizable: true
5455
- scope:
5556
path: "_topics"
5657
values:
5758
layout: topic
5859
permalink: /en/topics/:title/
60+
localizable: false
5961

6062
collections:
6163
topics:
6264
output: true
6365

6466
languages:
65-
- ja
66-
- es
67+
- code: ja
68+
name: Japanese
69+
- code: es
70+
name: Spanish
6771

6872
## In-text aliases
6973
trb: "709,632" # TapRoot Block (activation)
+12-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{% assign baseurl = page.permalink | remove_first: "/" | remove_first: page.lang %}
2-
3-
{% for lang in site.languages %}
4-
{% assign localization = "/" | append: lang | append:baseurl %}
5-
{% assign locale = site.posts | where:"permalink", localization %}
6-
{% assign localizations = localizations | concat: locale %}
7-
{% endfor %}
2+
<div class="localization">
3+
<a href="{{ '/en' | append:baseurl }}">en</a>
4+
{% for lang in site.languages %}
5+
{% assign localization = "/" | append: lang.code | append:baseurl %}
6+
{% assign locale = site.posts | where:"permalink", localization %}
7+
{% if locale.size == 0 %}
8+
| <span title="No {{lang.name}} translation currently available">{{ lang.code }}</span>
9+
{% else %}
10+
| <a href="{{ locale[0].url }}">{{lang.code}}</a>
11+
{% endif %}
12+
{% endfor %}
13+
</div>

_layouts/blog.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ layout: default
77
<div class="localization">
88
<a href="/en/blog/">en</a>
99
{% for lang in site.languages %}
10-
| <a href="/{{ lang }}/blog/">{{lang}}</a>
10+
| <a href="/{{ lang.code }}/blog/">{{lang.code}}</a>
1111
{% endfor %}
1212
</div>
1313

_layouts/newsletter.html

+1-10
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,9 @@
33
---
44
<link rel="stylesheet" href="/assets/css/main.css">
55

6-
{% include functions/localization-finder.md %}
7-
86
<article class="newsletter">
97
<header class="post-header">
10-
{% if localizations.size > 0 %}
11-
<div class="localization">
12-
<a href="{{ '/en' | append:baseurl }}">en</a>
13-
{% for locale in localizations %}
14-
| <a href="{{ locale.url }}">{{locale.lang}}</a>
15-
{% endfor %}
16-
</div>
17-
{% endif %}
8+
{% include functions/localization-finder.md %}
189
{% assign year = page.date | date: "%Y" %}
1910
{% assign path = "/" | append: page.lang | append: "/newsletters/" | append: year | append: "/" %}
2011
{% include linkers/breadcrumbs.md path=path %}

_layouts/newsletters.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ layout: default
77
<div class="localization">
88
<a href="/en/newsletters/">en</a>
99
{% for lang in site.languages %}
10-
| <a href="/{{ lang }}/newsletters/">{{lang}}</a>
10+
| <a href="/{{ lang.code }}/newsletters/">{{lang.code}}</a>
1111
{% endfor %}
1212
</div>
1313

_layouts/post.html

+3-9
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@
33
---
44
<link rel="stylesheet" href="/assets/css/main.css">
55

6-
{% include functions/localization-finder.md %}
6+
{% assign baseurl = page.permalink | remove_first: "/" | remove_first: page.lang %}
77

88
<article class="post">
9-
109
<header class="post-header">
11-
{% if localizations.size > 0 %}
12-
<div class="localization">
13-
<a href="{{ '/en' | append:baseurl }}">en</a>
14-
{% for locale in localizations %}
15-
| <a href="{{ locale.url }}">{{locale.lang}}</a>
16-
{% endfor %}
17-
</div>
10+
{% if page.localizable %}
11+
{% include functions/localization-finder.md %}
1812
{% endif %}
1913
{% include linkers/breadcrumbs.md path=page.url %}
2014
<h1 class="post-title">{{ page.title | escape }}</h1>

_layouts/publications.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ layout: default
77
<div class="localization">
88
<a href="/en/publications/">en</a>
99
{% for lang in site.languages %}
10-
| <a href="/{{ lang }}/publications/">{{lang}}</a>
10+
| <a href="/{{ lang.code }}/publications/">{{lang.code}}</a>
1111
{% endfor %}
1212
</div>
1313

assets/css/main.scss

+6
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ div.compat-usability img
249249
div.localization
250250
{
251251
text-align: right;
252+
253+
span {
254+
font-style: italic;
255+
color:gray;
256+
cursor: not-allowed;
257+
}
252258
}
253259

254260
.pc125 {

0 commit comments

Comments
 (0)