Skip to content

Commit

Permalink
linguam-scriptum-i18n (#11): fiat lux!
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed May 21, 2021
1 parent 5e081db commit 659f3da
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 57 deletions.
33 changes: 15 additions & 18 deletions _data/api.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# https://github.com/avillafiorita/jekyll-datapage_gen


# Trivia
# - 'x-default':
# - https://en.wikipedia.org/wiki/Hreflang
Expand Down Expand Up @@ -40,7 +37,7 @@
## -----------------------------------------------------------------------------
- x-default: /mul/api/UN/HDX/
uid: /mul/api/UN/HDX/
linguam: mul
linguam: mul-Zyyy
typum: api
gid: UN
lid: HDX
Expand All @@ -49,7 +46,7 @@

- x-default: /mul/api/UN/HDX/
# uid: /eng/api/UN/humanitarian-data-exchange/
linguam: eng
linguam: eng-Latn
typum: api
gid: UN
lid: HDX
Expand All @@ -62,7 +59,7 @@
# Hapi toolchain
- x-default: /mul/api/UN/HDX/
# uid: /arb/api/UN/اختبارات/
linguam: arb
linguam: arb-Arab
typum: api
gid: UN
lid: 'اختبارات'
Expand All @@ -73,7 +70,7 @@
## -----------------------------------------------------------------------------
- x-default: /mul/api/UN/reliefweb/
# uid: /mul/api/UN/reliefweb/
linguam: mul
linguam: mul-Zyyy
typum: api
gid: UN
lid: reliefweb
Expand All @@ -82,7 +79,7 @@

- x-default: /mul/api/UN/reliefweb/
# uid: /eng/api/UN/reliefweb/
linguam: eng
linguam: eng-Latn
typum: api
gid: UN
lid: reliefweb
Expand All @@ -95,7 +92,7 @@
## -----------------------------------------------------------------------------
- x-default: /mul/api/UN/CODV2API/
# uid: /mul/api/UN/CODV2API/
linguam: mul
linguam: mul-Zyyy
typum: api
gid: UN
lid: CODV2API
Expand All @@ -104,7 +101,7 @@

- x-default: /mul/api/UN/CODV2API/
# uid: /eng/api/UN/common-operational-datasets-api/
linguam: eng
linguam: eng-Latn
typum: api
gid: UN
lid: common-operational-datasets-api
Expand All @@ -118,7 +115,7 @@
## -----------------------------------------------------------------------------
- x-default: /mul/api/XZ/HXL-Proxy/
# uid: /mul/api/XZ/HXL-Proxy/
linguam: mul
linguam: mul-Zyyy
typum: api
gid: XZ
lid: hxl-proxy
Expand All @@ -127,7 +124,7 @@

- x-default: /mul/api/XZ/HXL-Proxy/
# uid: /eng/api/XZ/HXL-Proxy/
linguam: eng
linguam: eng-Latn
typum: api
gid: XZ
lid: hxl-proxy
Expand All @@ -141,7 +138,7 @@
## -----------------------------------------------------------------------------
- x-default: /mul/api/BR/portais-ckan-brasil/
# uid: /mul/api/BR/portais-ckan-brasil/
linguam: mul
linguam: mul-Zyyy
typum: api
gid: BR
lid: portais-ckan-brasil
Expand All @@ -150,7 +147,7 @@

- x-default: /mul/api/BR/portais-ckan-brasil/
# uid: /eng/api/BR/brazilian-ckan-portals/
linguam: eng
linguam: eng-Latn
typum: api
gid: BR
lid: brazilian-ckan-portals
Expand All @@ -163,7 +160,7 @@

- x-default: /mul/api/BR/portais-ckan-brasil/
# uid: /por/api/BR/dados-abertos-ckan-brasil/
linguam: por
linguam: por-Latn
typum: api
gid: BR
lid: dados-abertos-ckan-brasil
Expand All @@ -177,7 +174,7 @@
## -----------------------------------------------------------------------------
- x-default: /mul/api/BR/portais-arcgis-brasil/
# uid: /mul/api/BR/portais-arcgis-brasil/
linguam: mul
linguam: mul-Zyyy
typum: api
gid: BR
lid: portais-arcgis-brasil
Expand All @@ -186,7 +183,7 @@

- x-default: /mul/api/BR/portais-arcgis-brasil/
# uid: /por/api/BR/portais-arcgis-brasil/
linguam: por
linguam: por-Latn
typum: api
gid: BR
lid: portais-arcgis-brasil
Expand All @@ -200,7 +197,7 @@
# Note: jekyll-datapage-generator.rb needs fix for non-latin alphabet
# - gid: api/UN
# lid: ReliefWeb
# linguam: eng
# linguam: eng-Latn
# openapi_filum: /api/UN/reliefweb/eng/openapi.yaml
# slug: "اختبارات"
# noindex: true
Expand Down
5 changes: 5 additions & 0 deletions _data/operarium/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# _data/operarium

> Trivia:
> - 'operārium'
> - https://en.wiktionary.org/wiki/operarius
34 changes: 22 additions & 12 deletions _data/referens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,35 @@
# - https://en.wiktionary.org/wiki/scopus#Latin
# - https://en.wiktionary.org/wiki/scope#English
# - "front-matter-defaults"
# - https://jekyllrb.com/docs/configuration/front-matter-defaults/
# - https://jekyllrb.com/docs/configuration/front-matter-defaults/
# - BCP47
# - https://en.wikipedia.org/wiki/IETF_language_tag
# - https://www.rfc-editor.org/info/bcp47
# - https://datatracker.ietf.org/doc/html/rfc4647
# - https://datatracker.ietf.org/doc/html/rfc5646

linguam:
eng:
locale: en

arb-Arab:
BCP47: ar
eng-Latn:
BCP47: en
## Noticia:
## [por] Em geral, vamos usar Português (genérico) e evitar usar pt_BR
## ou pt_PT. Isso faz sentido em outras línguas onde a diferença é
## muito mais significativa, porém português escrito tem pouca
## variações
por:
locale: pt
## _[por] Em geral, vamos usar Português (genérico) e evitar usar pt_BR
## ou pt_PT. Isso faz sentido em outras línguas onde a diferença é
## muito mais significativa, porém português escrito tem pouca
## variações
## [por]_
por-Latn:
BCP47: pt
por-BR:
locale: pt_BR
BCP47: pt-BR
por-PT:
locale: pt_PT
BCP47: pt-PT
mul-Zyyy:
BCP47: ''


### Temp
# - https://en.wikipedia.org/wiki/IETF_language_tag
# - https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
# - https://translatewiki.net/wiki/ISO_15924
32 changes: 14 additions & 18 deletions _plugins/hapi/utilitatem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def digitum_premendum(item)

# _[eng] Macro to 'expand' user written api data to new variables [eng]_
# _[por] Macro para 'expandir' o que usuário escreveu [por]_
def expandendum_api_datum(apis)
def expandendum_api_datum(apis, referens)
apis.map do |api|
# puts api['uid']
api['uid'] = "/#{api['linguam']}/#{api['typum']}/#{api['gid']}/#{api['lid']}/"
Expand All @@ -55,25 +55,25 @@ def expandendum_api_datum(apis)
# puts api['uid']
# api['openapi_filum'] = openapi_filum_de_api(api)
# api = expandendum_api_datum_jekyll_page(api)
expandendum_api_datum_jekyll_page(api)
expandendum_api_datum_jekyll_page(api, referens)
end

apis
end

# _[eng] Macro to 'expand' user written api data to new variables [eng]_
# _[por] Macro para 'expandir' o que usuário escreveu [por]_
def expandendum_api_datum_jekyll_page(api)
def expandendum_api_datum_jekyll_page(api, referens)
@hreflang = if xdefault_est(api)
'x-default'
else
linguam_to_html_lang(api['linguam'])
linguam_to_html_lang(api['linguam'], referens)
end
puts @hreflang
api['jekyll-page'] = {
# 'locale' => Utilitatem.linguam_to_html_lang(api['linguam']),
'linguam' => api['linguam'],
'lang' => linguam_to_html_lang(api['linguam']),
'lang' => linguam_to_html_lang(api['linguam'], referens),
'hreflang' => @hreflang,
'title' => api['namen'] || api['title'],
'description' => api['description'] || api['descriptionem'],
Expand All @@ -89,21 +89,17 @@ def expandendum_api_datum_jekyll_page(api)

# _[eng] We use ISO 639-3, but HTML lang wants BCP-47 [eng]_
# _[por] Usamos ISO 639-3, porém HTML lang deseja BCP-47 [por]_
def linguam_to_html_lang(linguam)
@referens = {
'arb' => 'ar',
'arb-Arab' => 'ar',
'eng' => 'en',
'eng-Latn' => 'en',
'por' => 'pt',
'por-Latn' => 'pt',
'lat' => 'la',
'lat-Latn' => 'la',
'mul' => 'pt'
}
def linguam_to_html_lang(linguam, referens)
if referens['linguam'][linguam].nil?
puts "ERROR! linguam_to_html_lang referens #{linguam}!"
return nil
end

# puts referens['linguam'][linguam]['BCP47']

# puts linguam
# puts @referens[linguam]
@referens[linguam]
referens['linguam'][linguam]['BCP47']
end

# _[eng] Clean control chars and white space from names [eng]_
Expand Down
4 changes: 2 additions & 2 deletions _plugins/jekyll_hapi_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class HapiApiGenerator < Jekyll::Generator

def generate(site)
@debug_all = false

@apis = Utilitatem.expandendum_api_datum(site.data['api'])
# puts site.data['referens']
@apis = Utilitatem.expandendum_api_datum(site.data['api'], site.data['referens'])

# _[eng] We override site.data.api [eng]_
# _[por] Sobrescrevemos o site.data.api [por]_
Expand Down
6 changes: 2 additions & 4 deletions _plugins/jekyll_hapi_hooks.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# https://jekyllrb.com/docs/plugins/hooks/

# frozen_string_literal: true
## https://womanonrails.com/ruby-iterators

# Jekyll::Hooks.register :site, :after_init do |site|
Expand Down Expand Up @@ -31,16 +31,14 @@
api['locale'] = 'pt'
when 'lat'
api['locale'] = 'la'
default
when 'mul'
api['locale'] = 'pt'
end
end

puts 'jekyll-hapi-hooks: bye!'
end

# TODO: fechar sitemap e menus

# Jekyll::Hooks.register :pages, :post_init do |page|
# # code to call after Jekyll renders a page
# puts page
Expand Down
11 changes: 8 additions & 3 deletions documentum/mappam-situm.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
<div class="container">
<h1>Mappam Situm - Auxilium Humanitarium API documentōrum</h1>
<div class="alert alert-danger" role="alert">
<p lang="eng">[eng]👷🏽 Work in progress</p>
<p lang="pt">[por]👷🏽 Trabalho em progresso</p>
<p lang="en">👷🏽 Work in progress</p>
<p lang="pt">👷🏽 Trabalho em progresso</p>
</div>
</div>
</header>
Expand All @@ -53,10 +53,15 @@ <h2>Trivia</h2>
<li><a href="https://en.wiktionary.org/wiki/mappa#Latin">https://en.wiktionary.org/wiki/mappa#Latin</a></li>
</ul>
</li>
<li><samp>pāginam</samp>
<ul>
<li><a href="https://en.wiktionary.org/wiki/pagina#Latin">https://en.wiktionary.org/wiki/pagina#Latin</a></li>
</ul>
</li>
</ul>
</p>
</article>
<h2>Pages</h2>
<h2>Pāginam</h2>
<ul>
{% for post in site.pages %}
<li>
Expand Down

0 comments on commit 659f3da

Please sign in to comment.