Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ The gem provides built-in localization for some languages:
- `:nl` - Dutch
- `:zh` - Chinese
- `:ja` - Japanese
- `:ru` - Russian
- `:ar` - Arabic

These defaults include proper date/time formats, day and month names, and number formatting that follows each language's conventions. You can check out a full example of all supported keys [in this folder](lib/mini_i18n/locales/).

Expand Down
17 changes: 17 additions & 0 deletions lib/mini_i18n/locales/ar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ar:
date:
formats:
default: "%A %-d %B %Y"
short: "%d/%m/%y"
day_names: [الأحد, الاثنين, الثلاثاء, الأربعاء, الخميس, الجمعة, السبت]
abbr_day_names: [أحد, اثن, ثلا, أرب, خمي, جمع, سبت]
month_names: [يناير, فبراير, مارس, أبريل, مايو, يونيو, يوليو, أغسطس, سبتمبر, أكتوبر, نوفمبر, ديسمبر]
abbr_month_names: [ينا, فبر, مار, أبر, ماي, يون, يول, أغس, سبت, أكت, نوف, ديس]
time:
formats:
default: "%a %-d %B %Y - %H:%M"
short: "%d/%m/%y - %H:%M"
number:
format:
delimiter: ','
separator: '.'
17 changes: 17 additions & 0 deletions lib/mini_i18n/locales/ru.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ru:
date:
formats:
default: "%A, %-d %B %Y г."
short: "%d.%m.%y"
day_names: [воскресенье, понедельник, вторник, среда, четверг, пятница, суббота]
abbr_day_names: [вс, пн, вт, ср, чт, пт, сб]
month_names: [январь, февраль, март, апрель, май, июнь, июль, август, сентябрь, октябрь, ноябрь, декабрь]
abbr_month_names: [янв, фев, мар, апр, май, июн, июл, авг, сен, окт, ноя, дек]
time:
formats:
default: "%a, %-d %B %Y г. - %H:%M"
short: "%d.%m.%y - %H:%M"
number:
format:
delimiter: ' '
separator: ','
10 changes: 9 additions & 1 deletion spec/default_locales_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
before(:each) do
@original_translations = MiniI18n.translations.dup
@original_available_locales = MiniI18n.available_locales.dup
MiniI18n.available_locales = [:en, :es, :fr, :de, :pt, :it, :nl, :zh, :ja]
MiniI18n.available_locales = [:en, :es, :fr, :de, :pt, :it, :nl, :zh, :ja, :ru, :ar]
end

after(:each) do
Expand All @@ -26,6 +26,8 @@
expect(MiniI18n.l(date, locale: :nl)).to eq("maandag 25 december 2023")
expect(MiniI18n.l(date, locale: :zh)).to eq("2023年12月25日")
expect(MiniI18n.l(date, locale: :ja)).to eq("2023年12月25日(月)")
expect(MiniI18n.l(date, locale: :ru)).to eq("понедельник, 25 декабрь 2023 г.")
expect(MiniI18n.l(date, locale: :ar)).to eq("الاثنين 25 ديسمبر 2023")
end

it "formats short dates according to each locale" do
Expand All @@ -38,6 +40,8 @@
expect(MiniI18n.l(date, format: :short, locale: :nl)).to eq("25-12-23")
expect(MiniI18n.l(date, format: :short, locale: :zh)).to eq("12月25日")
expect(MiniI18n.l(date, format: :short, locale: :ja)).to eq("12/25")
expect(MiniI18n.l(date, format: :short, locale: :ru)).to eq("25.12.23")
expect(MiniI18n.l(date, format: :short, locale: :ar)).to eq("25/12/23")
end
end

Expand All @@ -52,6 +56,8 @@
expect(MiniI18n.l(time, locale: :nl)).to eq("ma 25 december 2023 - 14:30")
expect(MiniI18n.l(time, locale: :zh)).to eq("2023年12月25日 星期一 14:30")
expect(MiniI18n.l(time, locale: :ja)).to eq("2023年12月25日(月) 14時30分")
expect(MiniI18n.l(time, locale: :ru)).to eq("пн, 25 декабрь 2023 г. - 14:30")
expect(MiniI18n.l(time, locale: :ar)).to eq("اثن 25 ديسمبر 2023 - 14:30")
end
end

Expand All @@ -66,6 +72,8 @@
expect(MiniI18n.l(number, locale: :nl)).to eq("1.234,56")
expect(MiniI18n.l(number, locale: :zh)).to eq("1,234.56")
expect(MiniI18n.l(number, locale: :ja)).to eq("1,234.56")
expect(MiniI18n.l(number, locale: :ru)).to eq("1 234,56")
expect(MiniI18n.l(number, locale: :ar)).to eq("1,234.56")
end
end
end