FEATURE: English locale with international date formats

FEATURE: English locale with international date formats

Makes en_US the new default locale

diff --git a/Dangerfile b/Dangerfile
index 72c02d7..667918b 100644
--- a/Dangerfile
+++ b/Dangerfile
@@ -13,8 +13,8 @@ This PR doesn't match our required code formatting standards, as enforced by pre
   })
 end
 
-locales_changes = git.modified_files.grep(/config\/locales/)
-has_non_en_locales_changes = locales_changes.grep_v(/config\/locales\/(client|server)\.en\.yml/).any?
+locales_changes = git.modified_files.grep(%r{config/locales})
+has_non_en_locales_changes = locales_changes.grep_v(%r{config/locales/(?:client|server)\.(?:en|en_US)\.yml}).any?
 
 if locales_changes.any? && has_non_en_locales_changes
   fail("Please submit your non-English translation updates via [Transifex](https://www.transifex.com/discourse/discourse-org/). You can read more on how to contribute translations [here](https://meta.discourse.org/t/contribute-a-translation-to-discourse/14882).")
diff --git a/app/assets/javascripts/locales/en_US.js.erb b/app/assets/javascripts/locales/en_US.js.erb
new file mode 100644
index 0000000..7c4cccc
--- /dev/null
+++ b/app/assets/javascripts/locales/en_US.js.erb
@@ -0,0 +1,5 @@
+//= depend_on 'client.en_US.yml'
+//= require locales/i18n
+
+<% JsLocaleHelper.reloadable_plugins(:en_US, self) %>
+<%= JsLocaleHelper.output_locale(:en_US) %>
diff --git a/app/assets/javascripts/wizard/test/test_helper.js b/app/assets/javascripts/wizard/test/test_helper.js
index fada802..3d26843 100644
--- a/app/assets/javascripts/wizard/test/test_helper.js
+++ b/app/assets/javascripts/wizard/test/test_helper.js
@@ -17,7 +17,7 @@
 //= require_tree ./acceptance
 //= require_tree ./models
 //= require_tree ./components
-//= require locales/en
+//= require locales/en_US
 //= require fake_xml_http_request
 //= require route-recognizer/dist/route-recognizer
 //= require pretender/pretender
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 892380a..1075233 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -324,7 +324,7 @@ class ApplicationController < ActionController::Base
       locale = current_user.effective_locale
     end
 
-    I18n.locale = I18n.locale_available?(locale) ? locale : :en
+    I18n.locale = I18n.locale_available?(locale) ? locale : SiteSettings::DefaultsProvider::DEFAULT_LOCALE
     I18n.ensure_all_loaded!
   end
 
diff --git a/app/jobs/base.rb b/app/jobs/base.rb
index b34e3f1..aae9c8a 100644
--- a/app/jobs/base.rb
+++ b/app/jobs/base.rb
@@ -221,7 +221,7 @@ module Jobs
           RailsMultisite::ConnectionManagement.with_connection(db) do
             job_instrumenter = JobInstrumenter.new(job_class: self.class, opts: opts, db: db, jid: jid)
             begin
-              I18n.locale = SiteSetting.default_locale || "en"
+              I18n.locale = SiteSetting.default_locale || SiteSettings::DefaultsProvider::DEFAULT_LOCALE
               I18n.ensure_all_loaded!
               begin
                 logster_env = {}
diff --git a/app/models/locale_site_setting.rb b/app/models/locale_site_setting.rb
index 5f3d7f1..4e5522a 100644
--- a/app/models/locale_site_setting.rb
+++ b/app/models/locale_site_setting.rb
@@ -57,7 +57,14 @@ class LocaleSiteSetting < EnumSiteSetting
     end
   end
 
+  FALLBACKS ||= {
+    en_US: :en
+  }
+
   def self.fallback_locale(locale)
+    fallback_locale = FALLBACKS[locale.to_sym]
+    return fallback_locale if fallback_locale
+
     plugin_locale = DiscoursePluginRegistry.locales[locale.to_s]
     plugin_locale ? plugin_locale[:fallbackLocale]&.to_sym : nil
   end
diff --git a/app/models/translation_override.rb b/app/models/translation_override.rb
index 3d205f1..9dcf718 100644
--- a/app/models/translation_override.rb
+++ b/app/models/translation_override.rb
@@ -66,8 +66,7 @@ class TranslationOverride < ActiveRecord::Base
 
   def check_interpolation_keys
     original_text = I18n.overrides_disabled do
-      # lookup is protected
-      I18n.backend.send(:lookup, self.locale, self.translation_key)
+      I18n.t(translation_key, locale: :en)
     end
 
     if original_text
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 01f4713..c51848c 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -38,31 +38,31 @@ en:
         millions: "{{number}}M"
     dates:
       # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
-      time: "h:mm a"
+      time: "HH:mm"
       # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
       timeline_date: "MMM YYYY"
       # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
-      long_no_year: "MMM D h:mm a"
+      long_no_year: "D MMM HH:mm"
       # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
-      long_no_year_no_time: "MMM D"
+      long_no_year_no_time: "D MMM"
       # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
-      full_no_year_no_time: "MMMM Do"
+      full_no_year_no_time: "Do MMMM"
       # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
-      long_with_year: "MMM D, YYYY h:mm a"
+      long_with_year: "D MMM YYYY HH:mm"
       # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
-      long_with_year_no_time: "MMM D, YYYY"
+      long_with_year_no_time: "D MMM YYYY"
       # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
-      full_with_year_no_time: "MMMM Do, YYYY"
+      full_with_year_no_time: "D MMMM YYYY"
       # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
-      long_date_with_year: "MMM D, 'YY LT"
+      long_date_with_year: "D MMM 'YY LT"
       # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
-      long_date_without_year: "MMM D, LT"
+      long_date_without_year: "D MMM LT"
       # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
-      long_date_with_year_without_time: "MMM D, 'YY"
+      long_date_with_year_without_time: "D MMM 'YY"
       # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
-      long_date_without_year_with_linebreak: "MMM D <br/>LT"
+      long_date_without_year_with_linebreak: "D MMM <br/>LT"
       # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
-      long_date_with_year_with_linebreak: "MMM D, 'YY <br/>LT"
+      long_date_with_year_with_linebreak: "D MMM 'YY <br/>LT"
 
       wrap_ago: "%{date} ago"
 
@@ -98,7 +98,9 @@ en:
         almost_x_years:
           one: "1y"
           other: "%{count}y"
-        date_month: "MMM D"
+        # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
+        date_month: "D MMM"
+        # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
         date_year: "MMM 'YY"
       medium:
         x_minutes:
@@ -110,7 +112,8 @@ en:
         x_days:
           one: "1 day"
           other: "%{count} days"
-        date_year: "MMM D, 'YY"
+        # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
+        date_year: "D MMM 'YY"
       medium_with_ago:
         x_minutes:
           one: "1 min ago"
diff --git a/config/locales/client.en_US.yml b/config/locales/client.en_US.yml
new file mode 100644
index 0000000..683baf5
--- /dev/null
+++ b/config/locales/client.en_US.yml
@@ -0,0 +1,38 @@
+en_US:
+  js:
+    dates:
+      # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
+      time: "h:mm a"
+      # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
+      timeline_date: "MMM YYYY"
+      # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
+      long_no_year: "MMM D h:mm a"
+      # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/
+      long_no_year_no_time: "MMM D"

[... diff too long, it was truncated ...]

GitHub sha: b7889489

1 Like