Skip to content

Commit

Permalink
Hapi.Translationem + Hapi.HXL: primeira versão quaaase funcional usan…
Browse files Browse the repository at this point in the history
…do novo padrão

HXL-CPLP/forum#58, hapi-t9n-alpha (#13), mvp-l10n-schemas (#7)
  • Loading branch information
fititnt committed May 29, 2021
1 parent e2afced commit c2717f9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 79 deletions.
2 changes: 2 additions & 0 deletions _data/referens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ linguam:
eng-Latn:
BCP47: en
hxlattrs: # deprecated
- "+i_en+i_eng+is_latn"
- "+i_eng+is_latn"
- "+i_eng"
- "+i_en"
Expand All @@ -91,6 +92,7 @@ linguam:
spa-Latn:
BCP47: es
hxlattrs: # deprecated
- "+i_es+i_spa+is_latn"
- "+i_spa+is_latn"
- "+i_spa"
- "+i_es"
Expand Down
82 changes: 26 additions & 56 deletions _plugins/hapi/hxl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,93 +109,63 @@ def hashtag_exemplum
def quod_obiectum_optionem_existendum(obiectum)
opts = _chaves_relevantes(obiectum)
uglyhack = hashtag_exemplum
# puts 'quod_columnam'
# puts ''
# puts ''
# puts ''
# puts ' referens'
# puts @referens
# puts ' opts'
# puts opts
# puts ' uglyhack'
# puts uglyhack
# # puts obiectum.keys
# # puts opt
# # puts obiectum

# puts ' opts.any?'
# # puts opts.any? @referens

unless @referens.any? { |ref| opts.include?(ref) }
# log.debug("Created Logger")
puts "Hapi.HXL.HXLOptionem: non referens [#{referens}]"
puts " > Hapi.HXL.HXLOptionem: non referens [#{referens}]"
return false
end
unless uglyhack.any? { |ref| opts.include?(ref) }
# puts "Hapi.HXL.HXLOptionem: non obiectum_optionem [#{uglyhack}]"
puts "Hapi.HXL.HXLOptionem: non obiectum_optionem [#{uglyhack}][#{opts}]"
puts " > Hapi.HXL.HXLOptionem: non obiectum_optionem [#{uglyhack}][#{opts}]"
# log.debug("Created Logger")
return false
end

# puts 'encontrou'
puts 'encontrou'
true
end

# Trivia:
# - 'valendum'
# - https://en.wiktionary.org/wiki/valeo#Latin
def quod_obiectum_valendum(obiectum, referens)
def quod_obiectum_valendum(obiectum, referens_valendum)
# opts = _chaves_relevantes(obiectum)

@referens.each do |key|
# puts 'referens'
# puts @referens
@referens.each do |hxlkey|
# unless obiectum[key].nil? || obiectum[key] != referens
# return true
# end
return obiectum[key] unless obiectum[key].nil? || obiectum[key] != referens
# puts "referens_valendum [#{referens_valendum}]"
# puts "hxlkey [#{hxlkey}]"
# puts "obiectum[hxlkey] [#{obiectum[hxlkey]}]"
# puts obiectum[key]
next if obiectum[hxlkey].nil? || obiectum[hxlkey] != referens_valendum

# return obiectum[key] unless obiectum[key].nil? || obiectum[key] != referens

puts "quod_obiectum_valendum #{referens_valendum} #{referens}: #{obiectum}"

# TODO: agora procure a chave certa, nao retorne a mesma key :)
return _chave_com_resultado_de_objeto_certo(obiectum)
end

return false

# uglyhack = hashtag_exemplum
# # puts 'quod_columnam'
# # puts ''
# # puts ''
# # puts ''
# # puts ' referens'
# # puts @referens
# # puts ' opts'
# # puts opts
# # puts ' uglyhack'
# # puts uglyhack
# # # puts obiectum.keys
# # # puts opt
# # # puts obiectum

# # puts ' opts.any?'
# # # puts opts.any? @referens

# unless @referens.any? { |ref| opts.include?(ref) }
# # log.debug("Created Logger")
# puts "Hapi.HXL.HXLOptionem: non referens [#{referens}]"
# return false
# end
# unless uglyhack.any? { |ref| opts.include?(ref) }
# # puts "Hapi.HXL.HXLOptionem: non obiectum_optionem [#{uglyhack}]"
# puts "Hapi.HXL.HXLOptionem: non obiectum_optionem [#{uglyhack}][#{opts}]"
# # log.debug("Created Logger")
# return false
# end

# # puts 'encontrou'
# true
"TODO retorna valor exato se existir"
end

private

def _chave_com_resultado_de_objeto_certo(obiectum)
uglyhack = hashtag_exemplum
uglyhack.each do |hxlkey|
puts 'ENCONTRADO!' if obiectum.key?(hxlkey)
return obiectum[hxlkey] if obiectum.key?(hxlkey)
end
raise "_chave_com_resultado_de_objeto_certo: non resultatum [#{uglyhack}] [#{obiectum}]"
end

def _chaves_relevantes(obiectum)
obiectum.keys

Expand Down
30 changes: 8 additions & 22 deletions _plugins/jekyll_hapi_translationem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def translationem_memoriam_rememorandum(contextum, codicem, linguam = nil)
tm[archivum[0]].each do |tm_item|
val = hxloptionem.quod_obiectum_valendum(tm_item, codicem)
# puts 'val'
puts "#{codicem}, #{linguam}: #{val}" unless val == false
# puts "#{codicem}, #{linguam}: #{val}" unless val == false
return val unless val == false
end

Expand All @@ -359,13 +359,12 @@ def translationem_memoriam_rememorandum(contextum, codicem, linguam = nil)

# return HXL.testum(tm_item, hxloptionem)
# end

false
end

# puts 'hxlattrs'
# puts hxlattrs
# puts contextum['site']['data'].keys

false
end

# rubocop:enable Metrics/MethodLength
Expand Down Expand Up @@ -459,31 +458,18 @@ def initialize(tag_name, text, tokens)
end

def render(context)
temp = Translationem.datum_temporarium(context)
# temp = Translationem.datum_temporarium(context)
# l10nval = Translationem.datum_l10n(@textum, context, @linguam_fontem)
# l10nval = nil

# Translationem.translationem_memoriam_collectionem(context)
# puts Translationem.translationem_memoriam_rememorandum(context, @textum)
l10nval = Translationem.translationem_memoriam_rememorandum(context, @textum)
# l10nval = 'tes'
# raise l10nval if l10nval
return l10nval if l10nval != false

return l10nval if l10nval

return temp[@textum] if temp && temp[@textum]

suffixes = Translationem.datum_temporarium_suffix(context)

suffixes.each do |suffix|
# puts 'oooooooooi'
# puts suffix
# puts "#{@textum}#{suffix}"
# puts temp["#{@textum}#{suffix}"]
return Translationem.de(temp["#{@textum}#{suffix}"]) if temp && temp["#{@textum}#{suffix}"]
end

# "<!--[de_linguam:[#{@linguam_fontem}]]-->#{@textum}<!--[[#{@linguam_fontem}]:de_linguam]-->"
# "_[#{@linguam_fontem}]#{@textum}[#{@linguam_fontem}]_"
@textum.to_s
"[?#{@textum}?]"
end
end

Expand Down
2 changes: 1 addition & 1 deletion documentum/por-Latn/schema/iso/639-3/iso639-3.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
linguam: por-Latn
# linguam: por-Latn
# linguam: eng-Latn
# linguam: spa-Latn
permalink: /por-Latn/schema/iso639-3.json
# categories: [ index ]
Expand Down

0 comments on commit c2717f9

Please sign in to comment.