Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SMILES] Add Nederlands - Belgium locale #51

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ gem "decidim-time_tracker", git: "https://github.com/Platoniq/decidim-module-tim
# gem "deface"

gem "bootsnap", "~> 1.4"
# bug in version 1.9
gem "i18n", "~> 1.8.1"

gem "puma", ">= 4.3.5"
gem "uglifier", "~> 4.1"
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
//= require_tree .
//= require decidim
//= require smiles.platoniq.net
//= require datepicker-locales/foundation-datepicker.nl-BE.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Dutch translation for foundation-datepicker
* Reinier Goltstein <[email protected]>
*/
;
(function($) {
$.fn.fdatepicker.dates['nl-BE'] = {
days: ["Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"],
daysShort: ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo"],
daysMin: ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo"],
months: ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"],
monthsShort: ["Jan", "Feb", "Mrt", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
today: "Vandaag"
};
}(jQuery));
31 changes: 31 additions & 0 deletions app/forms/translatable_presence_validator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

#
# Bugfix backported from https://github.com/decidim/decidim/pull/8795/files
#
# A custom validator to check for presence in I18n-enabled fields. In order to
# use it do the following:
#
# validates :my_i18n_field, translatable_presence: true
#
# This will automatically check for presence for the default locale of the form
# object (or the `default_locale` of the form's organization) for the given field.
class TranslatablePresenceValidator < ActiveModel::EachValidator
def validate_each(record, attribute, _value)
translated_attr = "#{attribute}_#{default_locale_for(record)}".gsub("-", "__")
record.errors.add(translated_attr, :blank) if record.send(translated_attr).blank?
end

private

def default_locale_for(record)
return record.default_locale if record.respond_to?(:default_locale)

if record.current_organization
record.current_organization.default_locale
else
record.errors.add(:current_organization, :blank)
Decidim.default_locale
end
end
end
4 changes: 2 additions & 2 deletions config/initializers/decidim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Change these lines to set your preferred locales
config.default_locale = :en
config.available_locales = [:en, :ca, :es, :nl, :lv, :el, :pt]
config.available_locales = [:en, :ca, :es, :nl, :lv, :el, :pt, "nl-BE"]

# Geocoder configuration
config.maps = {
Expand Down Expand Up @@ -130,4 +130,4 @@
Rails.application.config.i18n.default_locale = Decidim.default_locale

Decidim::Api::Schema.max_complexity = 5000
Decidim::Api::Schema.max_depth = 50
Decidim::Api::Schema.max_depth = 50
3 changes: 3 additions & 0 deletions config/locales/nl-BE.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nl-BE:
locale:
name: Nederlands (Belgium)
3 changes: 2 additions & 1 deletion spec/lib/overrides_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
package: "decidim-core",
files: {
# layouts
"/app/views/layouts/decidim/_mini_footer.html.erb" => "55a9ca723b65b8d9eadb714818a89bb3"
"/app/views/layouts/decidim/_mini_footer.html.erb" => "55a9ca723b65b8d9eadb714818a89bb3",
"/app/forms/translatable_presence_validator.rb" => "a0dfc39805f27769edb917e9d30a8d67"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@
config.order = :random

config.before do
I18n.available_locales = [:en, :es, :ca, :nl]
I18n.available_locales = [:en, :es, :ca, :nl, "nl-BE"]
I18n.default_locale = :en
I18n.locale = :en
Decidim.available_locales = [:en, :es, :ca, :nl]
Decidim.available_locales = [:en, :es, :ca, :nl, "nl-BE"]
Decidim.default_locale = :en
Capybara.server = :puma
end
Expand Down