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

Explicitly attempt to resolve i18n-specific and english-fallback documents as two separate steps #28728

Merged
merged 2 commits into from May 24, 2019

Conversation

Hamms
Copy link
Contributor

@Hamms Hamms commented May 23, 2019

The current way we attempt to find localized templates leverages
extension names to make the localized version visible, and relies on
search ordering to make sure it gets selected first.

We'd like to implement some tweaks to the way we handle extension names
to allow for more dynamic template processing, but that becomes
difficult to do when the locale is also handled as an extension name.

With this change, we explicitly attempt to find the locale-specific
version of a file first by treating the locale as part of the
filename, not the extension name. This will both unblock us to make
tweaks to extension names and make the locale-vs-fallback functionality
more explicit.

…ments as two separate steps

The current way we attempt to find localized templates leverages
extension names to make the localized version visible, and relies on
search ordering to make sure it gets selected first.

We'd like to implement some tweaks to the way we handle extension names
to allow for more dynamic template processing, but that becomes
difficult to do when the locale is also handled as an extension name.

With this change, we explicitly attempt to find the locale-specific
version of a file first by treating the locale as part of the
_filename_, not the extension name. This will both unblock us to make
tweaks to extension names and make the locale-vs-fallback functionality
more explicit.
@Hamms Hamms changed the title Explicitly attempt to resolve i18n-specific and english-fallback docu… Explicitly attempt to resolve i18n-specific and english-fallback documents as two separate steps May 23, 2019
@Hamms Hamms requested a review from breville May 23, 2019 23:06
@@ -226,7 +226,8 @@ def self.set_max_age(type, default)

# Documents
get_head_or_post '*' do |uri|
pass unless path = resolve_document(uri)
path = resolve_document("#{uri}.#{request.locale}") || resolve_document(uri)
Copy link
Member

Choose a reason for hiding this comment

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

Whenever I see two possible code paths (separated by the || here) I think a comment could be helpful to explain the difference between the primary and the fallback path, and what would cause one to hit versus the other.

Copy link
Member

@breville breville left a comment

Choose a reason for hiding this comment

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

I'm not familiar with this existing path, but this approach seems reasonable, so long as it doesn't break anything :)

@breville
Copy link
Member

Correction: I totally added that path back in #25806 so I guess I am familiar with it. :)

@Hamms Hamms requested a review from breville May 24, 2019 00:18
@Hamms Hamms force-pushed the pegasus-explicit-i18n-resolve branch from f5c7dae to 877cce0 Compare May 24, 2019 01:11
@Hamms Hamms merged commit d184b09 into staging May 24, 2019
@Hamms Hamms deleted the pegasus-explicit-i18n-resolve branch May 24, 2019 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants