Skip to content

Commit

Permalink
mvp-tema-i18n (#9): _includes/fn/Conatum-corpus.liquid, MVP
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed May 14, 2021
1 parent 9994bb9 commit 61c20fd
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 27 deletions.
6 changes: 3 additions & 3 deletions _data/Temporarium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# - "fallback"
# - https://en.wiktionary.org/wiki/fallback

temp1: |
varnamen: |
<p>
No message
</p>
temp1eng: |
varnameneng: |
<p>
Note: this section allows you to interactively preview OpenAPI files
and even execute requests from your browser without leaving the
Expand All @@ -28,7 +28,7 @@ temp1eng: |
so let us know!
</p>
temp1por: |
varnamenpor: |
<p>
Nota: esta seção permite pré- visualizar de forma interativa arquivos OpenAPI
e até mesmo executar requisições do seu navegador sem sair do site hapi.etica.ai
Expand Down
22 changes: 22 additions & 0 deletions _data/linguam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# FILUM: _data/linguam.yml
# Trivia:
# - 'temporārium'
# - https://en.wiktionary.org/wiki/temporarius#Latin
# - cōnātum
# - https://en.wiktionary.org/wiki/conatus#Latin
# - retractum
# - https://en.wiktionary.org/wiki/retractus#Latin
# - "fallback"
# - https://en.wiktionary.org/wiki/fallback

canatum:
eng:
- "eng"
- "por"
- "lat"
por:
- "por"
- "eng"
- "lat"
lat:
- "lat"
71 changes: 52 additions & 19 deletions _includes/fn/Conatum-corpus.liquid
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
{% comment %}
Conatum-corpus.liquid try select the first availible data from
_data/Temporarium.yml
FILE: _includes/fn/Conatum-corpus.liquid
USAGE:
\{\% include fn/Conatum prefix='varnamen' suffix='por' \%\}
\{\% include fn/Conatum prefix='varnamenpor' suffix=false \%\}
(if page.linguam: por, suffix is not need)
\{\% include fn/Conatum prefix='varerror,varnamen' \%\}
\{\% include fn/Conatum prefix='varnamen' \%\}
\{\% include fn/Conatum prefix='varnamen' suffix='sfx1,sfx2' \%\}
DESCRIPTION: ---
OPTIONS: prefix:
prefix of variable (can be a list ',' or array)
suffix (optional):
suffix of variable (can be a list ',' or array)
default: uses _data/linguam.yml and page.linguam
AUTHOR: Emerson Rocha <rocha[at]ieee.org>
LICENSE: Public Domain dedication
SPDX-License-Identifier: Unlicense
VERSION: v1.0
CREATED: 2021-05-14 20:44 UTC started
REVISION: ---
{% endcomment %}

{% comment %} testum = [], initialize an array {% endcomment %}
{% assign testum = "" | split: ',' %}

{% if include.prefix %}
{% comment %}Array? String with , ?{% endcomment %}
{% if include.prefix[0] %}
Expand All @@ -12,6 +34,7 @@ _data/Temporarium.yml
{% assign prefix_est = include.prefix | remove: " " | split: "," %}
{% endif %}
{% else %}
?![Conatum [NOPREFIXERROR]?!
{% assign prefix_est = nil %}
{% endif %}

Expand All @@ -23,23 +46,37 @@ _data/Temporarium.yml
{% assign suffix_est = include.suffix | remove: " " | split: "," %}
{% endif %}
{% else %}
{% assign suffix_est = nil %}
{% comment %}
suffix not array.
If not == false (this would disable try add suffixes), we will use
page.linguam and _data/linguam.yml to try alternatives
{% endcomment %}
{% if include.suffix == false }
{% assign suffix_est = nil %}
{% else %}
{% capture suffix_est %}{{ site.data.linguam.canatum[page.linguam] | join: "," }}{% endcapture %}
{% assign suffix_est = suffix_est | split: ',' %}
{% endif %}
{% endif %}

{% comment %}
prefix_est
{{ prefix_est | json }}

{% comment %} prefix_est
{{ prefix_est | inspect }}
suffix_est
{{ suffix_est | json }}
{% endcomment %}
{{ suffix_est | inspect }} {% endcomment %}


{% assign resultatum_okay = false %}

{% comment %}
This is a loop.
{% endcomment %}
{% for prefix in prefix_est %}
{% unless resultatum_okay == true %}
{% if suffix_est == nil %}
{% comment %} {{ testum | inspect }} {% endcomment %}
{% assign testum = testum | push: prefix %}
{% comment %} {{ prefix | inspect }} {% endcomment %}
{{ testum | inspect }}

{% if site.data.Temporarium[prefix] %}
{{ site.data.Temporarium[prefix] }}
{% assign resultatum_okay = true %}
Expand All @@ -48,21 +85,17 @@ This is a loop.
{% else %}
{% for suffix in suffix_est %}
{% capture prefix_suffix %}{{ prefix }}{{ suffix }}{% endcapture %}
{% assign testum = testum | push: prefix_suffix %}
{% if site.data.Temporarium[prefix_suffix] %}
{{ site.data.Temporarium[prefix_suffix] }}
{% assign resultatum_okay = true %}
{{ break }}
{% break %}
{% endif %}
{% endfor %}
{% endif %}
{% endunless %}
{% endfor %}

{% comment %}
[[[[[{{ prefix_est | json }}]]]]]
[[[[[{{ suffix_est | inpect }}]]]]]
{% endcomment %}

{% if resultatum_okay != true %}
!!Conatum [{{ include | inpect }}]!!
{% endif %}
?![Conatum [{{ include | inpect }}] [testum [{{ testum | inspect }}]]]?!
{% endif %}
10 changes: 5 additions & 5 deletions _layouts/api.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
layout: defallo
fallback_langs: ['lat', 'por', 'eng']
---

<!-- {% include fn/Conatum prefix='temp1' suffix='lat,' %}

<br>
<br> -->
---
<br><br><br>


{% include fn/Conatum prefix='varnamen' %}


{% include fn/Conatum prefix='temp1' suffix=page.fallback_langs %}

<div style="border-style: dotted; border-width: 2px; border-color: #ccc">

Expand Down

0 comments on commit 61c20fd

Please sign in to comment.