Class: IsoDoc::Jis::I18n

Inherits:
Iso::I18n
  • Object
show all
Defined in:
lib/isodoc/jis/i18n.rb

Instance Method Summary collapse

Instance Method Details

#japanese_date(date, japanese_numbering: false) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/isodoc/jis/i18n.rb', line 21

def japanese_date(date, japanese_numbering: false)
  branch = japanese_numbering ? "japanese_numbering" : "default"
  fmts = @labels.dig("date_format", branch) || {}
  IsoDoc::ExtendedDateFormatter.format_iso_date(
    date,
    lang: "ja",
    year: fmts["year"],
    year_month: fmts["year_month"],
    full: fmts["full"],
  )
end

#jis_load_file(fname) ⇒ Object



7
8
9
10
# File 'lib/isodoc/jis/i18n.rb', line 7

def jis_load_file(fname)
  f = File.join(File.dirname(__FILE__), fname)
  File.exist?(f) ? YAML.load_file(f) : {}
end

#load_yaml1(lang, script) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/isodoc/jis/i18n.rb', line 12

def load_yaml1(lang, script)
  y = jis_load_file("i18n-#{yaml_lang(lang, script)}.yaml")
  if y.empty?
    jis_load_file("i18n-en.yaml").merge(super)
  else
    super.deep_merge(y)
  end
end