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

Do not hardcode locale unless certainly necessary #6791

Merged
merged 1 commit into from Feb 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/jekyll.rb
Expand Up @@ -35,7 +35,6 @@ def require_all(path)
require "i18n"

SafeYAML::OPTIONS[:suppress_warnings] = true
I18n.config.available_locales = :en

module Jekyll
# internal requires
Expand Down
5 changes: 4 additions & 1 deletion lib/jekyll/utils.rb
Expand Up @@ -203,7 +203,10 @@ def slugify(string, mode: nil, cased: false)
end

# Drop accent marks from latin characters. Everything else turns to ?
string = ::I18n.transliterate(string) if mode == "latin"
if mode == "latin"
I18n.config.available_locales = :en if I18n.config.available_locales.empty?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we set available_locales to an array ([:en]) instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think its necessary.
If you were to add a print I18n.config.available_locales immediately after this line, the output would return [:en]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks for checking!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code only gets run if mode is set to latin. If it's not you break everyone else's code by removing I18n.config.available_locales = :en from jekyll module which is exactly what happened to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milosgajdos83 I18n.config.available_locales = :en was specifically added to the Jekyll module for the sole use in the slugify filter.
Please open a new separate issue for better tracking..

string = I18n.transliterate(string)
end

slug = replace_character_sequence_with_hyphen(string, :mode => mode)

Expand Down