diff --git a/CHANGELOG.md b/CHANGELOG.md
index a59fd53e..944cf7f9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).
### Fixed
- bug with locales yaml creation
+- es locale file will be copied into app if Spanish requested
+- thumbnail size in `public.yml` requires quotation marks for newer psyche yaml gem
### Added
- partials for browse, browse_facet, index, and search_preset header content for easier overriding
@@ -44,8 +46,11 @@ Versioning](https://semver.org/spec/v2.0.0.html).
- `language` (head)
### Changed
-- `ALL_LANGUAGES` setting changed back to `languages`
- language documentation clarified and expanded
+- references to `APP_OPTS["languages"]` changed to use `all_languages`
+
+### Migration
+- rename `languages` and `ALL_LANGUAGES` to `all_languages` in `public.yml` file
## [v3.1.0](https://github.com/CDRH/orchid/compare/v3.0.3...v3.1.0) - search_preset, improved section links, and misc display
diff --git a/app/helpers/orchid/application_helper.rb b/app/helpers/orchid/application_helper.rb
index e31ccb0e..d53266d5 100644
--- a/app/helpers/orchid/application_helper.rb
+++ b/app/helpers/orchid/application_helper.rb
@@ -182,8 +182,8 @@ def locale
end
def locale_link(lang_code)
- locales = APP_OPTS["languages"].split("|")
- .reject { |l| l == APP_OPTS["language_default"] }.join("|")
+ locales = APP_OPTS["all_languages"].split("|")
+ .reject { |l| l == APP_OPTS["all_language_default"] }.join("|")
url = request.fullpath
if lang_code == APP_OPTS["language_default"]
diff --git a/app/views/layouts/body/_languages.html.erb b/app/views/layouts/body/_languages.html.erb
index d66308c5..fb30b0f4 100644
--- a/app/views/layouts/body/_languages.html.erb
+++ b/app/views/layouts/body/_languages.html.erb
@@ -1,4 +1,4 @@
-<% langs = APP_OPTS["languages"] %>
+<% langs = APP_OPTS["all_languages"] %>
<% if langs.present? && langs[/\|/] %>
diff --git a/app/views/layouts/head/_language.html.erb b/app/views/layouts/head/_language.html.erb
index 7922ff32..3bc2c2b4 100644
--- a/app/views/layouts/head/_language.html.erb
+++ b/app/views/layouts/head/_language.html.erb
@@ -1,6 +1,7 @@
<%# links for alternate language pages %>
-<% if APP_OPTS["languages"].present? && APP_OPTS["languages"][/\|/] %>
- <% APP_OPTS["languages"].split("|").each do |lang_code| %>
+<% langs = APP_OPTS["all_languages"] %>
+<% if langs.present? && langs[/\|/] %>
+ <% langs.split("|").each do |lang_code| %>
<%# if this is the currently selected language
then no alternative link is needed for it %>
<% next if lang_code == I18n.locale.to_s %>
diff --git a/lib/generators/setup_generator.rb b/lib/generators/setup_generator.rb
index 137b9ab1..6493e268 100755
--- a/lib/generators/setup_generator.rb
+++ b/lib/generators/setup_generator.rb
@@ -76,9 +76,6 @@ def copy_configs_and_locales
"#{@new_app}/config/private.yml")
FileUtils.cp("#{@this_app}/lib/generators/templates/public.yml",
"#{@new_app}/config/public.yml")
- # en locale file is always copied by default
- FileUtils.cp("#{@this_app}/config/locales/en.yml",
- "#{@new_app}/config/locales/en.yml")
puts "Please enter the following for initial app customization"
@@ -87,12 +84,11 @@ def copy_configs_and_locales
langs = prompt_for_value("All languages, including primary (separated with a pipe: en|es|cz)",
"en")
- config_set("public", "languages", langs)
+ config_set("public", "all_languages", langs)
all_langs = langs.blank? ? [] : langs.split("|")
all_langs.each do |lang|
- # for each language which is not english, create a locale file
- next if lang == "en"
+ # create a locale file for each specified language
copy_locale(lang)
end
@@ -111,7 +107,7 @@ def copy_configs_and_locales
# pre-made translations. Users will need to supply their own values for the
# strings in the file.
- Array(langs).each do |lang|
+ all_langs.each do |lang|
config_set("locales/#{lang}", "project_name", project_name,
uncomment: true)
config_set("locales/#{lang}", "project_shortname", project_shortname,
@@ -129,6 +125,10 @@ def copy_configs_and_locales
config_set("public", "media_server_dir", answer)
answer = prompt_for_value("Thumbnail Size (default: !200,200)", "!200,200")
+ # due to the exclamation mark, this needs to be surrounded in quotation marks
+ if !answer[/^".*"$/]
+ answer = "\"#{answer}\""
+ end
config_set("public", "thumbnail_size", answer)
# private config customization
@@ -172,9 +172,19 @@ def copy_initializer
end
def copy_locale(lang)
- FileUtils.cp("#{@this_app}/config/locales/en.yml",
- "#{@new_app}/config/locales/#{lang}.yml")
- gsub_file "#{@new_app}/config/locales/#{lang}.yml", /^en:$/, "#{lang}:"
+ supported_langs = [ "en", "es" ]
+
+ if supported_langs.include?(lang)
+ # by default, copy the locale files of any languages Orchid supports over
+ FileUtils.cp("#{@this_app}/config/locales/#{lang}.yml",
+ "#{@new_app}/config/locales/#{lang}.yml")
+ else
+ # for non-supported languages, copy the english template with the expectation
+ # that it will be translated into the correct language
+ FileUtils.cp("#{@this_app}/config/locales/en.yml",
+ "#{@new_app}/config/locales/#{lang}.yml")
+ gsub_file "#{@new_app}/config/locales/#{lang}.yml", /^en:$/, "#{lang}:"
+ end
end
def copy_remaining_templates
diff --git a/lib/generators/templates/public.yml b/lib/generators/templates/public.yml
index eaf6b3e3..93549054 100644
--- a/lib/generators/templates/public.yml
+++ b/lib/generators/templates/public.yml
@@ -9,7 +9,7 @@ default: &default
# defaults to "en" (english) if no default language set
language_default: en
# pipe delineated codes for all languages, e.g. "en|es|cz"
- ALL_LANGUAGES: en
+ all_languages: en
# for application title settings, please alter the files in config/locales
# IMAGES
diff --git a/lib/orchid/routing.rb b/lib/orchid/routing.rb
index c72bb338..fdce541d 100644
--- a/lib/orchid/routing.rb
+++ b/lib/orchid/routing.rb
@@ -9,8 +9,8 @@ def draw(section: "", routes: [], scope: "")
# If multiple languages, constrain locale to non-default language codes
locales = nil
- if defined?(APP_OPTS) && APP_OPTS["languages"].present?
- other_languages = APP_OPTS["languages"].split("|")
+ if defined?(APP_OPTS) && APP_OPTS["all_languages"].present?
+ other_languages = APP_OPTS["all_languages"].split("|")
.reject { |l| l == APP_OPTS["language_default"] }
if other_languages.present?