Skip to content

Use context.locale instead of ::I18n.locale#814

Merged
drujensen merged 5 commits into
masterfrom
unknown repository
May 27, 2018
Merged

Use context.locale instead of ::I18n.locale#814
drujensen merged 5 commits into
masterfrom
unknown repository

Conversation

@docelic
Copy link
Copy Markdown
Contributor

@docelic docelic commented May 23, 2018

This commit makes the locale choice thread-safe.

The corresponding changes to the citrine-i18n shard have already been made.

Fixes #776.

This commit makes the locale choice thread-safe.

The corresponding changes to the citrine-i18n shard
have already been made.

Fixes #776.
@docelic
Copy link
Copy Markdown
Contributor Author

docelic commented May 23, 2018

@faustinoaq HTTP::Server::Context is expanded with property "locale" inside citrine-i18n shard. But it appears that inside Amber in the place where test fails, "locale" isn't seen. Got any suggestions how to solve it?

(One possible solution would be to extent Context with "locale" inside Amber, and not inside citrine-i18n. Do we do that or there are some other ideas?)

@faustinoaq
Copy link
Copy Markdown
Contributor

@docelic I think you need to delegate :locale to context here:

BTW, I just realize test error are being printed twice, Can we fix that?

amber/spec/build_spec.cr

Lines 54 to 67 in f84fe8c

it "can be executed" do
puts spec_result unless spec_result.includes? "Finished in"
spec_result.should contain "Finished in"
end
it "has no errors" do
puts spec_result if spec_result.includes? "Error in line"
spec_result.should_not contain "Error in line"
end
it "has no failures" do
puts spec_result if spec_result.includes? "Failures"
spec_result.should_not contain "Failures"
end

We should puts spec_results once IMO 😅 /cc @eliasjpr

Something like this:

puts spec_result # => We can use just one puts here because spec_results output without errors are minimal

it "can be executed" do
    spec_result.should contain "Finished in"
end

it "has no errors" do
    spec_result.should_not contain "Error in line"
end

it "has no failures" do
    spec_result.should_not contain "Failures"
end

@docelic
Copy link
Copy Markdown
Contributor Author

docelic commented May 24, 2018

@faustinoaq Hm, if I am understanding the error correctly, the problem is not that "locale" doesn't exist, but rather that "context.locale" doesn't exist, which means that somehow Amber::Controller::Helpers::I18n's methods t() and l() were checked before citrine-i18n was required and before it added the property "locale" to Context.

@docelic
Copy link
Copy Markdown
Contributor Author

docelic commented May 24, 2018

Looks like the update to citrine-i18n v0.2.0 solved the issue, and the current error reported by travis is not directly related to the code.

Could someone check/confirm that's the case? Thanks!

@faustinoaq
Copy link
Copy Markdown
Contributor

Outdated shard.lock (wrong resolver). Please run shards update instead.

Why? Aren't CI tests created from scratch? 😅

Ref: https://travis-ci.org/amberframework/amber/jobs/382976615

@docelic
Copy link
Copy Markdown
Contributor Author

docelic commented May 26, 2018

Do we have an update here? Thanks!

@faustinoaq
Copy link
Copy Markdown
Contributor

Installing citrine-i18n (0.1.0 at 0.2.0)

@docelic Travis is still failing https://travis-ci.org/amberframework/amber/jobs/382976615#L731

You forgot to update 0.1.0 to 0.2.0 on https://github.com/amberframework/citrine-i18n/blob/master/shard.yml#L3 😅

@faustinoaq
Copy link
Copy Markdown
Contributor

@docelic
Copy link
Copy Markdown
Contributor Author

docelic commented May 26, 2018

@faustinoaq Oh great, thanks. I indeed forgot. I updated Amber's shard.yml to use the new version :) Thanks!

@faustinoaq
Copy link
Copy Markdown
Contributor

@docelic BTW, I already fixing recipes indentation based on your comment: amberframework/liquid.cr#31 (comment) 👍

Also, WDYT about moving src/locale to config/locate like rails ? 😅

@docelic
Copy link
Copy Markdown
Contributor Author

docelic commented May 26, 2018

It was originally @eliasjpr's suggestion that we put it in src/locale. Let's see his current thoughts on that.

Copy link
Copy Markdown
Contributor

@faustinoaq faustinoaq left a comment

Choose a reason for hiding this comment

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

Just waiting @eliasjpr opinion about moving src/locales to config/locales like rails 👍

@drujensen drujensen merged commit 975dc59 into amberframework:master May 27, 2018
@faustinoaq faustinoaq added this to the Version 0.8.0 milestone Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants