Skip to content

Commit

Permalink
Improve translation sitemaps
Browse files Browse the repository at this point in the history
  • Loading branch information
remibetin committed May 2, 2024
1 parent 888fd34 commit 6a25bbc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 47 deletions.
32 changes: 16 additions & 16 deletions _includes/t-status.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% assign versions=alldocs | where_exp:"item", "item.ref == include.page.url or item.url == include.page.url" %}
{% assign original=versions | where_exp:"item", "item.lang == 'en' or item.lang == nil" | first %}
{% assign t=versions | where_exp:"item", "item.lang == page.tlang" | first %}
{% assign translation=versions | where_exp:"item", "item.lang == page.tlang" | first %}

{%- capture page_title -%}
{%- capture original-title -%}
{%- if original.permalink != nil -%}
<p><a href="{{ original.permalink | relative_url }}">{{ original.title }}</a></p>
{%- elsif original.permalink == nil and include.page.name.en != nil -%}
Expand All @@ -12,31 +12,31 @@
{%- endif -%}
{%- endcapture -%}

{% capture t-date %}{{t.last_updated | date: '%s' | plus: 0 }}{% endcapture %}
{% capture en-date %}{{original.last_updated | date: '%s' | plus: 0 }}{% endcapture %}
{%- capture t_status -%}
{%- if t == nil -%}none
{%- elsif t.size != 0 and t-date < en-date -%}outdated
{%- elsif t.size != 0 and t-date >= en-date -%}uptodate
{% capture translation-date %}{{ translation.last_updated | date: '%s' | plus: 0 }}{% endcapture %}
{% capture original-date %}{{ original.last_updated | date: '%s' | plus: 0 }}{% endcapture %}
{%- capture t-status -%}
{%- if translation == nil -%}none
{%- elsif translation.size != 0 and translation-date < original-date -%}outdated
{%- elsif translation.size != 0 and translation-date >= original-date -%}uptodate
{%- endif -%}
{%- endcapture -%}

<tr>
<th>{{ page_title }}</th>
<th>{{ original-title }}</th>
<td>
{%- case t_status -%}
{%- case t-status -%}
{%- when "none" -%}
<p>{% include_cached icon.html name="ex-circle" %} No translation available</p>
<p>{% include_cached icon.html name="ex-circle" %} No translation</p>
{%- capture github-file-path -%}{% include_cached github-file-path.html p=original %}{%- endcapture -%}
<p><a class="button button-secondary" href="https://github.com/remibetin/wai-translations/issues/new?template=new-translation.yml&title=[{{ tlangname }}]+{{original.title | url_encode}}&url={{original.permalink | absolute_url | url_encode }}&github-link={{ github-link }}"><span>Volunteer to translate this page</span></a></p>
<p><a class="button button-secondary" href="https://github.com/remibetin/wai-translations/issues/new?template=new-translation.yml&title=[{{ tlangname }}]+{{original.title | url_encode}}&url={{original.permalink | absolute_url | url_encode }}&github-link={{ github-file-path }}"><span>Volunteer to translate this page</span></a></p>
{%- when "outdated" -%}
<p>{% include_cached icon.html name="warning" %} Translation needs update<p>
<p><mark><a href="{{ t.permalink | relative_url }}" lang="{{ tlang }}"> {{ t.title }}</a></mark></p>
{%- capture github-file-path -%}{% include_cached github-file-path.html p=t %}{%- endcapture -%}
<p><a class="button button-secondary" href="https://github.com/remibetin/wai-translations/issues/new?template=update-translation.yml&title=[{{ tlangname }}]+{{original.title | url_encode}}&url={{t.permalink | absolute_url | url_encode }}&github-link={{ github-link }}"><span>Volunteer to update the translation</span></a></p>
<p><mark><a href="{{ translation.permalink | relative_url }}" lang="{{ tlang }}"> {{ translation.title }}</a></mark></p>
{%- capture github-file-path -%}{% include_cached github-file-path.html p=translation %}{%- endcapture -%}
<p><a class="button button-secondary" href="https://github.com/remibetin/wai-translations/issues/new?template=update-translation.yml&title=[{{ tlangname }}]+{{original.title | url_encode}}&url={{translation.permalink | absolute_url | url_encode }}&github-link={{ github-file-path }}"><span>Volunteer to update the translation</span></a></p>
{%- when "uptodate" -%}
<p>{% include_cached icon.html name="check-circle" %} Up-to-date</p>
<p><a href="{{ t.permalink | relative_url }}" lang="{{ tlang }}"> {{ t.title }}</a></p>
<p><a href="{{ translation.permalink | relative_url }}" lang="{{ tlang }}"> {{ translation.title }}</a></p>
{%- endcase -%}
</td>
</tr>
55 changes: 24 additions & 31 deletions _layouts/translation-sitemap.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,6 @@
<div class="default-grid with-gap{% unless page.noleftcol %} leftcol{% endunless %}">

{% if page.sidebaricon %}
{% comment %}
This should be properly implemented in the styleguide, but it might be a one-off.
{% endcomment %}
<style>
.sidebaricon {
width: 100%;
display: block;
height: 292px;
color: var(--w3c-blue);
margin-top: 65px;
}
</style>
<div class="sidenav">
{% include_cached icon.html name=page.sidebaricon class="sidebaricon" %}
</div>
Expand Down Expand Up @@ -128,12 +116,6 @@ <h1>{% if page.title_icon %}
{% else %}
<header>
<h1>
{% if page.title_icon %}
<svg class="icon-in-title" aria-hidden="true"><use xlink:href="{{page.title_icon | relative_url}}"></use></svg>
{% endif %}
{% if page.title_image %}
<img src="{{page.title_image | relative_url }}" alt="" class="title-image right" style="height: 2em;">
{% endif %}
{% if page.title_html %}
{{ page.title_html }}
{% else %}
Expand All @@ -152,14 +134,16 @@ <h1>
{% endif %}

{%- include doc-note-msg.html -%}
{%- include translation-note-msg.html -%}

<!-- Start Translations sitemaps -->
{% assign tlangname=site.data.lang[page.tlang].name %}
{% assign alldocs=site.documents | concat: site.pages %}

{% include box.html type="start" h="2" title="Summary" class="full" %}

This page lists the status of {{ tlangname }} translations for most pages on the WAI website.
<p>This page lists the status of {{ tlangname }} translations, for WAI resources for which we welcome translations.</p>

<p>Learn how to use this translation sitemap in <a href="{{ /about/translating/sitemaps/ | relative_url }}#how-to-use">Translations Sitemaps</a> page.</p>

{% include box.html type="end" %}

Expand All @@ -183,7 +167,7 @@ <h2>Priorities Status</h2>
{%- for prio in site.data.translations-priorities -%}
{%- include t-status.html page=prio -%}
{%- for priosub in prio.pages -%}
{%- include t-status.html page=priosub-%}
{%- include t-status.html page=priosub -%}
{%- endfor -%}
{%- endfor -%}
</tbody>
Expand All @@ -205,7 +189,6 @@ <h3>
{%- endif -%}
</h3>
{% include excol.html type="middle" %}
{% assign pages=section.pages | where_exp:"item", "item.mainnav != false and item.hide != true and item.translate == true" -%}
<table class="quiet translations-table">
<thead>
<tr>
Expand All @@ -214,19 +197,29 @@ <h3>
</tr>
</thead>
<tbody>
{%- for p in pages -%}
{%- include t-status.html page=p lang=page.tlang -%}
{% assign subpages=p.pages | where_exp:"item", "item.mainnav != false and item.hide != true" -%}
{%- for subpage in subpages -%}
{%- include t-status.html page=subpage lang=page.tlang -%}
{% include box.html type="end" %}
{% endfor %}
{% include box.html type="end" %}
{% endfor %}
{%- assign pages=section.pages | where_exp:"item", "item.mainnav != false and item.hide != true" -%}
{%- for p in pages -%}
{% if p.translate == true %}
{%- include t-status.html page=p -%}
{% endif %}
{%- assign subpages=p.pages | where_exp:"item", "item.mainnav != false and item.hide != true" -%}
{%- for subpage in subpages -%}
{% if subpage.translate == true %}
{%- include t-status.html page=subpage -%}
{% endif %}
{%- assign subsubpages=subpage.pages | where_exp:"item", "item.mainnav != false and item.hide != true" -%}
{%- for subsubpage in subsubpages -%}
{% if subsubpage.translate == true %}
{%- include t-status.html page=subsubpage -%}
{% endif %}
{%- endfor -%}
{%- endfor -%}
{%- endfor -%}
</tbody>
</table>
{% include excol.html type="end" %}
{% endfor %}
<!-- End Translations sitemaps -->

{%- if page.navigation -%}
{%- include prevnext-navigation.html -%}
Expand Down

0 comments on commit 6a25bbc

Please sign in to comment.