-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
209 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
it: | ||
date: | ||
day_names: [domenica, lunedì, martedì, mercoledì, giovedì, venerdì, sabato] | ||
abbr_day_names: [dom, lun, mar, mer, gio, ven, sab] | ||
# Don't forget the nil at the beginning; there's no such thing as a 0th month | ||
month_names: [~, gennaio, febbraio, marzo, aprile, maggio, giugno, luglio, agosto, settembre, ottobre, novembre, dicembre] | ||
abbr_month_names: [~, gen, feb, mar, apr, mag, giu, lug, ago, set, ott, nov, dic] | ||
seasons: | ||
spring: "primavera" | ||
summer: "estate" | ||
autumn: "autunno" | ||
winter: "inverno" | ||
edtf: | ||
terms: | ||
approximate_date_prefix_day: "circa " | ||
approximate_date_prefix_month: "circa " | ||
approximate_date_prefix_year: "circa " | ||
approximate_date_suffix_day: "" | ||
approximate_date_suffix_month: "" | ||
approximate_date_suffix_year: "" | ||
decade_prefix: "anni " | ||
decade_suffix: "" | ||
century_suffix: "" | ||
interval_prefix_day: "" | ||
interval_prefix_month: "" | ||
interval_prefix_year: "" | ||
interval_connector_approximate: " - " | ||
interval_connector_open: " - " | ||
interval_connector_day: " - " | ||
interval_connector_month: " - " | ||
interval_connector_year: " - " | ||
interval_unspecified_suffix: "" | ||
open_start_interval_with_day: "fino a %{date}" | ||
open_start_interval_with_month: "fino a %{date}" | ||
open_start_interval_with_year: "fino a %{date}" | ||
open_end_interval_with_day: "%{date} - " | ||
open_end_interval_with_month: "%{date} - " | ||
open_end_interval_with_year: "%{date} - " | ||
set_dates_connector_exclusive: ", " | ||
set_dates_connector_inclusive: ", " | ||
set_earlier_prefix_exclusive: "prima di " | ||
set_earlier_prefix_inclusive: "prima di " | ||
set_last_date_connector_exclusive: " o " | ||
set_last_date_connector_inclusive: " e " | ||
set_later_prefix_exclusive: "dopo " | ||
set_later_prefix_inclusive: "dopo " | ||
set_two_dates_connector_exclusive: " o " | ||
set_two_dates_connector_inclusive: " e " | ||
uncertain_date_suffix: " ?" | ||
unknown: "data sconosciuta" | ||
unspecified_digit_substitute: "x" | ||
formats: | ||
day_precision_strftime_format: "%-d %B %Y" | ||
month_precision_strftime_format: "%B %Y" | ||
year_precision_strftime_format: "%Y" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
module Edtf | ||
module Humanize | ||
module Language | ||
module Italian | ||
include Default | ||
|
||
module Century | ||
extend self | ||
|
||
def humanizer(date) | ||
require 'roman' | ||
"#{(date.year.abs / 100 + 1).to_roman}" \ | ||
"#{century_number_suffix}" \ | ||
"#{century_sign_suffix(date)}" | ||
end | ||
|
||
private | ||
|
||
def century_number_suffix | ||
' secolo' | ||
end | ||
|
||
def century_sign_suffix(date) | ||
return ' a. C.' if date.year.negative? | ||
|
||
'' | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
module Edtf | ||
module Humanize | ||
VERSION = '2.0.0' | ||
VERSION = '2.0.1' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'edtf-humanize' | ||
|
||
RSpec.describe Edtf::Humanize do | ||
before do | ||
I18n.locale = :it | ||
end | ||
|
||
it { is_expected.to be_a(Module) } | ||
|
||
context 'with a decade' do | ||
it 'returns a humanized decade string' do | ||
expect(Date.edtf('199x').humanize).to eq('anni 1990') | ||
end | ||
end | ||
|
||
context 'with a century' do | ||
it 'returns a humanized century string' do | ||
expect(Date.edtf('19xx').humanize).to eq('XX secolo') | ||
end | ||
end | ||
|
||
context 'with an interval' do | ||
it 'returns a humanized interval string' do | ||
expect(Date.edtf('1970/1980').humanize).to eq('1970 - 1980') | ||
end | ||
end | ||
|
||
context 'with an open interval' do | ||
it 'returns a humanized interval string' do | ||
expect(Date.edtf('1970/open').humanize).to eq('1970 - ') | ||
end | ||
end | ||
|
||
context 'with an approximate interval' | ||
it 'returns a humanized approximate interval string' do | ||
expect(Date.edtf('1970~/1980~').humanize).to( | ||
eq('circa 1970 - circa 1980') | ||
) | ||
end | ||
|
||
context 'with an iso date' do | ||
it 'returns a humanized ISO date string' do | ||
expect(Date.edtf('1975-07-01').humanize).to eq('1 luglio 1975') | ||
end | ||
end | ||
|
||
context 'with an uncertain iso date' do | ||
it 'returns a humanized uncertain ISO date string' do | ||
expect(Date.edtf('1975?').humanize).to eq('1975 ?') | ||
end | ||
end | ||
|
||
context 'with an unspecified year iso date' do | ||
it 'returns a humanized unspecified year ISO date string' do | ||
expect(Date.edtf('197u').humanize).to eq('197x') | ||
end | ||
end | ||
|
||
context 'with a season' do | ||
it 'returns a humanized season string' do | ||
expect(Date.edtf('1975-22').humanize).to eq('estate 1975') | ||
end | ||
end | ||
|
||
context 'with a set' do | ||
it 'returns a humanized exclusive set string' do | ||
expect(Date.edtf('[1980, 1981, 1983]').humanize).to( | ||
eq('1980, 1981 o 1983') | ||
) | ||
end | ||
|
||
it 'returns a humanized inclusive set string' do | ||
expect(Date.edtf('{1980, 1981, 1983}').humanize).to( | ||
eq('1980, 1981 e 1983') | ||
) | ||
end | ||
|
||
it 'returns a humanized open (before) exclusive set string' do | ||
expect(Date.edtf('[..1980]').humanize).to( | ||
eq('prima di 1980') | ||
) | ||
end | ||
|
||
it 'returns a humanized open (after) exclusive set string' do | ||
expect(Date.edtf('[1980..]').humanize).to( | ||
eq('dopo 1980') | ||
) | ||
end | ||
|
||
it 'returns a humanized open (before) inclusive set string' do | ||
expect(Date.edtf('{..1980}').humanize).to( | ||
eq('prima di 1980') | ||
) | ||
end | ||
|
||
it 'returns a humanized open (after) inclusive set string' do | ||
expect(Date.edtf('{1980..}').humanize).to( | ||
eq('dopo 1980') | ||
) | ||
end | ||
end | ||
|
||
context 'with an unknown value' do | ||
it 'returns a humanized unknown string' do | ||
expect(Date.edtf('uuuu').humanize).to eq('data sconosciuta') | ||
end | ||
end | ||
end |