Skip to content

Commit ff1f434

Browse files
neveleriBug
andauthored
Support resolving ui-text using page.locale when available (#5439)
* Support resolving `ui-text` using `page.locale` when available * Use `include.locale | default: site.locale` and pass locale from parent includes --------- Co-authored-by: iBug <git@ibugone.com>
1 parent a283a94 commit ff1f434

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+208
-159
lines changed

_includes/archive-single.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% assign locale = include.locale | default: site.locale %}
12
{% if post.header.teaser %}
23
{% capture teaser %}{{ post.header.teaser }}{% endcapture %}
34
{% else %}
@@ -24,7 +25,7 @@ <h2 class="archive__item-title no_toc p-name" itemprop="headline">
2425
<a class="u-url" href="{{ post.url | relative_url }}" rel="permalink">{{ title }}</a>
2526
{% endif %}
2627
</h2>
27-
{% include page__meta.html type=include.type %}
28+
{% include page__meta.html locale=locale type=include.type %}
2829
{% if post.excerpt %}<p class="archive__item-excerpt p-summary" itemprop="description">{{ post.excerpt | markdownify | strip_html | truncate: 160 }}</p>{% endif %}
2930
</article>
3031
</div>

_includes/author-profile.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% assign locale = include.locale | default: site.locale %}
12
{% assign author = page.author | default: page.authors[0] | default: site.author %}
23
{% assign author = site.data.authors[author] | default: author %}
34

@@ -23,7 +24,7 @@ <h3 class="author__name p-name" itemprop="name">
2324
</div>
2425

2526
<div class="author__urls-wrapper">
26-
<button class="btn btn--inverse">{{ site.data.ui-text[site.locale].follow_label | remove: ":" | default: "Follow" }}</button>
27+
<button class="btn btn--inverse">{{ site.data.ui-text[locale].follow_label | remove: ":" | default: "Follow" }}</button>
2728
<ul class="author__urls social-icons">
2829
{% if author.location %}
2930
<li itemprop="homeLocation" itemscope itemtype="https://schema.org/Place">
@@ -42,7 +43,7 @@ <h3 class="author__name p-name" itemprop="name">
4243
{% if author.uri %}
4344
<li>
4445
<a href="{{ author.uri }}" itemprop="url" rel="me">
45-
<i class="fas fa-fw fa-link" aria-hidden="true"></i><span class="label">{{ site.data.ui-text[site.locale].website_label | default: "Website" }}</span>
46+
<i class="fas fa-fw fa-link" aria-hidden="true"></i><span class="label">{{ site.data.ui-text[locale].website_label | default: "Website" }}</span>
4647
</a>
4748
</li>
4849
{% endif %}
@@ -51,7 +52,7 @@ <h3 class="author__name p-name" itemprop="name">
5152
<li>
5253
<a href="mailto:{{ author.email }}" rel="me" class="u-email">
5354
<meta itemprop="email" content="{{ author.email }}" />
54-
<i class="fas fa-fw fa-envelope-square" aria-hidden="true"></i><span class="label">{{ site.data.ui-text[site.locale].email_label | default: "Email" }}</span>
55+
<i class="fas fa-fw fa-envelope-square" aria-hidden="true"></i><span class="label">{{ site.data.ui-text[locale].email_label | default: "Email" }}</span>
5556
</a>
5657
</li>
5758
{% endif %}
@@ -235,7 +236,7 @@ <h3 class="author__name p-name" itemprop="name">
235236
{% if author.vine %}
236237
<li>
237238
<a href="https://vine.co/u/{{ author.vine }}" itemprop="sameAs" rel="nofollow noopener noreferrer me">
238-
<i class="fab fa-fw fa-vine" aria-hidden="true"></i><span class="label">{{ site.data.ui-text[site.locale].email_label | default: "Email" }}</span>
239+
<i class="fab fa-fw fa-vine" aria-hidden="true"></i><span class="label">{{ site.data.ui-text[locale].email_label | default: "Email" }}</span>
239240
</a>
240241
</li>
241242
{% endif %}

_includes/breadcrumbs.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% assign locale = include.locale | default: site.locale %}
12
{% case site.category_archive.type %}
23
{% when "liquid" %}
34
{% assign path_type = "#" %}
@@ -19,11 +20,11 @@
1920
{% for crumb in crumbs offset: 1 %}
2021
{% if forloop.first %}
2122
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
22-
<a href="{{ '/' | relative_url }}" itemprop="item"><span itemprop="name">{{ site.data.ui-text[site.locale].breadcrumb_home_label | default: "Home" }}</span></a>
23+
<a href="{{ '/' | relative_url }}" itemprop="item"><span itemprop="name">{{ site.data.ui-text[locale].breadcrumb_home_label | default: "Home" }}</span></a>
2324

2425
<meta itemprop="position" content="{{ i }}" />
2526
</li>
26-
<span class="sep">{{ site.data.ui-text[site.locale].breadcrumb_separator | default: "/" }}</span>
27+
<span class="sep">{{ site.data.ui-text[locale].breadcrumb_separator | default: "/" }}</span>
2728
{% endif %}
2829
{% if forloop.last %}
2930
<li class="current"{% if page.locale %} lang="{{ page.locale }}"{% endif %}>{{ page.title }}</li>
@@ -33,7 +34,7 @@
3334
<a href="{{ crumb | downcase | replace: '%20', '-' | prepend: path_type | prepend: crumb_path | relative_url }}" itemprop="item"><span itemprop="name">{{ crumb | url_decode | replace: '-', ' ' | capitalize }}</span></a>
3435
<meta itemprop="position" content="{{ i }}" />
3536
</li>
36-
<span class="sep">{{ site.data.ui-text[site.locale].breadcrumb_separator | default: "/" }}</span>
37+
<span class="sep">{{ site.data.ui-text[locale].breadcrumb_separator | default: "/" }}</span>
3738
{% endif %}
3839
{% endfor %}
3940
</ol>

_includes/category-list.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% assign locale = include.locale | default: site.locale %}
12
{% case site.category_archive.type %}
23
{% when "liquid" %}
34
{% assign path_type = "#" %}
@@ -9,11 +10,11 @@
910
{% assign categories_sorted = page.categories | sort_natural %}
1011

1112
<p class="page__taxonomy">
12-
<strong><i class="fas fa-fw fa-folder-open" aria-hidden="true"></i> {{ site.data.ui-text[site.locale].categories_label | default: "Categories:" }} </strong>
13+
<strong><i class="fas fa-fw fa-folder-open" aria-hidden="true"></i> {{ site.data.ui-text[locale].categories_label | default: "Categories:" }} </strong>
1314
<span itemprop="keywords">
1415
{% for category_word in categories_sorted %}
1516
<a href="{{ category_word | slugify | prepend: path_type | prepend: site.category_archive.path | relative_url }}" class="page__taxonomy-item p-category" rel="tag">{{ category_word }}</a>{% unless forloop.last %}<span class="sep">, </span>{% endunless %}
1617
{% endfor %}
1718
</span>
1819
</p>
19-
{% endif %}
20+
{% endif %}

_includes/comments-providers/scripts.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% assign locale = include.locale | default: site.locale %}
12
{% if site.comments.provider and page.comments %}
23
{% case site.comments.provider %}
34
{% when "disqus" %}
@@ -7,9 +8,9 @@
78
{% when "facebook" %}
89
{% include /comments-providers/facebook.html %}
910
{% when "staticman" %}
10-
{% include /comments-providers/staticman.html %}
11+
{% include /comments-providers/staticman.html locale=locale %}
1112
{% when "staticman_v2" %}
12-
{% include /comments-providers/staticman_v2.html %}
13+
{% include /comments-providers/staticman_v2.html locale=locale %}
1314
{% when "utterances" %}
1415
{% include /comments-providers/utterances.html %}
1516
{% when "giscus" %}

_includes/comments-providers/staticman.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1+
{% assign locale = include.locale | default: site.locale %}
12
{% if site.repository and site.staticman.branch %}
23
<script>
34
(function ($) {
45
$('#new_comment').submit(function () {
56
var form = this;
67

78
$(form).addClass('disabled');
8-
$('#comment-form-submit').html('<i class="fas fa-spinner fa-spin fa-fw"></i> {{ site.data.ui-text[site.locale].loading_label | default: "Loading..." }}');
9+
$('#comment-form-submit').html('<i class="fas fa-spinner fa-spin fa-fw"></i> {{ site.data.ui-text[locale].loading_label | default: "Loading..." }}');
910

1011
$.ajax({
1112
type: $(this).attr('method'),
1213
url: $(this).attr('action'),
1314
data: $(this).serialize(),
1415
contentType: 'application/x-www-form-urlencoded',
1516
success: function (data) {
16-
$('#comment-form-submit').html('{{ site.data.ui-text[site.locale].comment_btn_submitted | default: "Submitted" }}');
17+
$('#comment-form-submit').html('{{ site.data.ui-text[locale].comment_btn_submitted | default: "Submitted" }}');
1718
$('.page__comments-form .js-notice').removeClass('notice--danger');
1819
$('.page__comments-form .js-notice').addClass('notice--success');
19-
showAlert('{{ site.data.ui-text[site.locale].comment_success_msg | default: "Thanks for your comment! It will show on the site once it has been approved." }}');
20+
showAlert('{{ site.data.ui-text[locale].comment_success_msg | default: "Thanks for your comment! It will show on the site once it has been approved." }}');
2021
},
2122
error: function (err) {
2223
console.log(err);
23-
$('#comment-form-submit').html('{{ site.data.ui-text[site.locale].comment_btn_submit | default: "Submit Comment" }}');
24+
$('#comment-form-submit').html('{{ site.data.ui-text[locale].comment_btn_submit | default: "Submit Comment" }}');
2425
$('.page__comments-form .js-notice').removeClass('notice--success');
2526
$('.page__comments-form .js-notice').addClass('notice--danger');
26-
showAlert('{{ site.data.ui-text[site.locale].comment_error_msg | default: "Sorry, there was an error with your submission. Please make sure all required fields have been completed and try again." }}');
27+
showAlert('{{ site.data.ui-text[locale].comment_error_msg | default: "Sorry, there was an error with your submission. Please make sure all required fields have been completed and try again." }}');
2728
$(form).removeClass('disabled');
2829
}
2930
});

_includes/comments-providers/staticman_v2.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1+
{% assign locale = include.locale | default: site.locale %}
12
{% if site.repository and site.comments.staticman.branch %}
23
<script>
34
(function ($) {
45
$('#new_comment').submit(function () {
56
var form = this;
67

78
$(form).addClass('disabled');
8-
$('#comment-form-submit').html('<i class="fas fa-spinner fa-spin fa-fw"></i> {{ site.data.ui-text[site.locale].loading_label | default: "Loading..." }}');
9+
$('#comment-form-submit').html('<i class="fas fa-spinner fa-spin fa-fw"></i> {{ site.data.ui-text[locale].loading_label | default: "Loading..." }}');
910

1011
$.ajax({
1112
type: $(this).attr('method'),
1213
url: $(this).attr('action'),
1314
data: $(this).serialize(),
1415
contentType: 'application/x-www-form-urlencoded',
1516
success: function (data) {
16-
$('#comment-form-submit').html('{{ site.data.ui-text[site.locale].comment_btn_submitted | default: "Submitted" }}');
17+
$('#comment-form-submit').html('{{ site.data.ui-text[locale].comment_btn_submitted | default: "Submitted" }}');
1718
$('.page__comments-form .js-notice').removeClass('notice--danger');
1819
$('.page__comments-form .js-notice').addClass('notice--success');
19-
showAlert('{{ site.data.ui-text[site.locale].comment_success_msg | default: "Thanks for your comment! It will show on the site once it has been approved." }}');
20+
showAlert('{{ site.data.ui-text[locale].comment_success_msg | default: "Thanks for your comment! It will show on the site once it has been approved." }}');
2021
},
2122
error: function (err) {
2223
console.log(err);
23-
$('#comment-form-submit').html('{{ site.data.ui-text[site.locale].comment_btn_submit | default: "Submit Comment" }}');
24+
$('#comment-form-submit').html('{{ site.data.ui-text[locale].comment_btn_submit | default: "Submit Comment" }}');
2425
$('.page__comments-form .js-notice').removeClass('notice--success');
2526
$('.page__comments-form .js-notice').addClass('notice--danger');
26-
showAlert('{{ site.data.ui-text[site.locale].comment_error_msg | default: "Sorry, there was an error with your submission. Please make sure all required fields have been completed and try again." }}');
27+
showAlert('{{ site.data.ui-text[locale].comment_error_msg | default: "Sorry, there was an error with your submission. Please make sure all required fields have been completed and try again." }}');
2728
$(form).removeClass('disabled');
2829
}
2930
});

0 commit comments

Comments
 (0)