GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allow overriding of entry resolving entry resolving separate from defaults by movermeyer · Pull Request #622 · ruby-i18n/i18n

Conversation

@movermeyer

@movermeyer movermeyer commented Feb 13, 2022

Copy link
Copy Markdown
Contributor

What are you trying to accomplish?

Fixes #617. Alternative to #620.

#591 was incorrect, since I didn't check/realize that resolve is called in three different cases:

  1. When the value found in the translation file is a Symbol (Code)
    • This was the case I handled in Resolve Symbols using the original fallback locale #591. In this case, you need/want to restart your search from the original fallback locale.
  2. When a value is not found, then values from defaults are resolved. (Code)
    • When resolving defaults, you want to do it only at the level of the current locale, before falling back.
    • i.e., Go through all defaults before falling back through fallbacks locales, keeping the behaviour as it has always been.
  3. When the value found in the translation file is something else, especially a Proc (Code)
    • This is the same case as 1., where you are resolving a entry, but I mention it separately since it is being called from a different place in the code.

Prior to #591, there was no distinction between the cases. #591 should have introduced that distinction.

What approach did you choose and why?

I added a resolve_entry method which can be overridden to handle the case of resolving an entry separately from resolving defaults. By default resolve_entry is an alias of resolve.

I then changed the calls to resolve to use resolve_entry in cases where they are resolving entries.

What should reviewers focus on?

🤷

The impact of these changes

Fixes #617.

Testing

I added the regression test from #620 to show that it works with the existing Rails calls.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@movermeyer movermeyer mentioned this pull request Feb 13, 2022
Revert #591, add a regression test for #617 #620
Closed
@movermeyer
Allow overriding of entry resolving entry resolving separate from def…
19f190d
…aults
@movermeyer
movermeyer force-pushed the movermeyer/resolve_defaults_with_current_locale branch from a5376cd to 19f190d Compare February 13, 2022 18:28
@radar

radar commented Feb 14, 2022

Copy link
Copy Markdown
Collaborator

LGTM, thank you @movermeyer for investigating this on a Sunday :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@radar

radar commented Feb 14, 2022

Copy link
Copy Markdown
Collaborator

The tests confirm it, but just to double check as well, I've used the repro app from #617 along with this new branch -- I can (double extra) confirm this branch fixes the issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@radar
radar merged commit 789d12e into ruby-i18n:master Feb 14, 2022
@Somestuffman Somestuffman mentioned this pull request Feb 14, 2022
can't modify frozen Hash: {} (FrozenError) #613
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG] Fallbacks do not work for Rails STI models

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@movermeyer @radar
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402605 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.