<script>
  if (Spree === undefined) {
    var Spree = {}
  }
  Spree.translations = <%==
    JSON.dump(
      I18n.t("spree").merge({
        abbr_day_names:         I18n.t(:abbr_day_names, scope: :date),
        month_names:            I18n.t(:month_names, scope: :date).reject(&:blank?),
        currency_separator:     I18n.t('number.currency.format.separator'),
        currency_delimiter:     I18n.t('number.currency.format.delimiter'),
        activerecord:           I18n.t('activerecord')
    }))
  %>;

  Spree.currencyInfo = <%==
    JSON.dump(
      Spree::Config.available_currencies.map { |c|
        format =
          if c.format.present?
            c.format.gsub("%u", "%s").gsub("%n", "%v")
          elsif c.symbol == "" || c.symbol_first
            "%s%v"
          else
            "%v %s"
          end

        [c.id.to_s.upcase, [
          c.symbol || "¤",
          c.exponent,
          format
        ]]
    }.to_h)
%>;
</script>
<script data-hook='admin-custom-translations'>
</script>

<% select2_locale_path = "solidus_admin/select2_locales/select2_locale_#{I18n.locale}.js" %>
<% if I18n.locale != :en && I18n.locale && (
    Rails.application.assets&.find_asset(select2_locale_path) || # compiled on the fly
    Rails.application.assets_manifest.assets[select2_locale_path] # precompiled
) %>
  <%= javascript_include_tag select2_locale_path, data: {turbolinks_track: 'reload'} %>
<% end %>
