From f4c233f59fc74ec4e6b78dadcd09ba800e56085b Mon Sep 17 00:00:00 2001 From: kibigo! Date: Thu, 7 Dec 2017 14:42:21 -0800 Subject: [PATCH] Ruby intl8n for themes --- app/javascript/flavours/glitch/names.yml | 6 ++++++ app/javascript/flavours/vanilla/names.yml | 6 ++++++ .../skins/vanilla/{win95.scss => win95/common.scss} | 0 app/javascript/skins/vanilla/win95/names.yml | 4 ++++ app/views/settings/preferences/show.html.haml | 4 ++-- config/initializers/locale.rb | 6 ++++++ 6 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 app/javascript/flavours/glitch/names.yml create mode 100644 app/javascript/flavours/vanilla/names.yml rename app/javascript/skins/vanilla/{win95.scss => win95/common.scss} (100%) create mode 100644 app/javascript/skins/vanilla/win95/names.yml create mode 100644 config/initializers/locale.rb diff --git a/app/javascript/flavours/glitch/names.yml b/app/javascript/flavours/glitch/names.yml new file mode 100644 index 0000000000..b3d579cb27 --- /dev/null +++ b/app/javascript/flavours/glitch/names.yml @@ -0,0 +1,6 @@ +en: + flavours: + glitch: Glitch Edition + skins: + glitch: + default: Default diff --git a/app/javascript/flavours/vanilla/names.yml b/app/javascript/flavours/vanilla/names.yml new file mode 100644 index 0000000000..8816fcb3ab --- /dev/null +++ b/app/javascript/flavours/vanilla/names.yml @@ -0,0 +1,6 @@ +en: + flavours: + vanilla: Vanilla Mastodon + skins: + vanilla: + default: Default diff --git a/app/javascript/skins/vanilla/win95.scss b/app/javascript/skins/vanilla/win95/common.scss similarity index 100% rename from app/javascript/skins/vanilla/win95.scss rename to app/javascript/skins/vanilla/win95/common.scss diff --git a/app/javascript/skins/vanilla/win95/names.yml b/app/javascript/skins/vanilla/win95/names.yml new file mode 100644 index 0000000000..2083084a27 --- /dev/null +++ b/app/javascript/skins/vanilla/win95/names.yml @@ -0,0 +1,4 @@ +en: + skins: + vanilla: + win95: Masto95 diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml index 9564c03991..e2e48a6998 100644 --- a/app/views/settings/preferences/show.html.haml +++ b/app/views/settings/preferences/show.html.haml @@ -27,8 +27,8 @@ .fields-group - if Themes.instance.flavours.size > 1 - = f.input :setting_flavour, collection: Themes.instance.flavours, label_method: lambda { |flavour| I18n.t("themes.#{flavour}", default: flavour) }, wrapper: :with_label, include_blank: false - = f.input :setting_skin, collection: Themes.instance.skins_for(current_flavour), label_method: lambda { |skin| I18n.t("themes.#{current_flavour}.skins.#{skin}", default: skin) }, wrapper: :with_label, include_blank: false + = f.input :setting_flavour, collection: Themes.instance.flavours, label_method: lambda { |flavour| I18n.t("flavours.#{flavour}", default: flavour) }, wrapper: :with_label, include_blank: false + = f.input :setting_skin, collection: Themes.instance.skins_for(current_flavour), label_method: lambda { |skin| I18n.t("skins.#{current_flavour}.#{skin}", default: skin) }, wrapper: :with_label, include_blank: false = f.input :setting_unfollow_modal, as: :boolean, wrapper: :with_label = f.input :setting_boost_modal, as: :boolean, wrapper: :with_label diff --git a/config/initializers/locale.rb b/config/initializers/locale.rb new file mode 100644 index 0000000000..04ed316465 --- /dev/null +++ b/config/initializers/locale.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +I18n.load_path += Dir[Rails.root.join('app', 'javascript', 'flavours', '*', 'names.{rb,yml}').to_s] +I18n.load_path += Dir[Rails.root.join('app', 'javascript', 'flavours', '*', 'names', '*.{rb,yml}').to_s] +I18n.load_path += Dir[Rails.root.join('app', 'javascript', 'skins', '*', '*', 'names.{rb,yml}').to_s] +I18n.load_path += Dir[Rails.root.join('app', 'javascript', 'skins', '*', '*', 'names', '*.{rb,yml}').to_s]