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

I18n lazy lookup, closes #272 #279

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

mbajur
Copy link

@mbajur mbajur commented Apr 15, 2015

Related to: #272

Ok, here is the raw module file. But still, after hundreds of attempts, i'm still not able to make it work as it should - using t('.something') is not being overwriten and produces an error. It would be great if you could advice me on how that module should be actually used with cells. Included by default? Included separately for each cell?

Sorry but i just think i'm missing something simple in here; no matter what i try, my overwrite is not visible from a single cell perspective and results in error

@mbajur mbajur changed the title I18n lazy lookop, closes #272 I18n lazy lookup, closes #272 Apr 15, 2015
@mbajur
Copy link
Author

mbajur commented Apr 15, 2015

To be more clear - adding my t method overwrite to specific cell class works fine but adding it anywhere in Cell::ViewModel don't

@apotonick
Copy link
Member

Ok - that's because the I18N module might be included after you defined your method and thus overwrites your beautiful method! I'll go through this soon!

@apotonick
Copy link
Member

@mbajur Can you add a test for that in a separate i18n_test.rb file? You can look up how to write such a test here: https://github.com/apotonick/cells/blob/master/test/url_helper_test.rb#L58

lib/cell/i18n.rb Outdated
def t(*args)
options = args.last.is_a?(Hash) ? args.pop.dup : {}
key = args.shift
cell_name = self.class.to_s.delete('Cell').underscore
Copy link

Choose a reason for hiding this comment

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

This is deleting too much from the name (e.g. 'MenuCell'.delete('Cell') # => 'Mnu') ... I'd suggest e.g. gsub(/Cell\Z/, '') instead.

Copy link
Author

Choose a reason for hiding this comment

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

yeah, that's exactly what i've done locally but forgot to send a PR for that. thanks

@mbajur
Copy link
Author

mbajur commented Jun 9, 2015

Yeah, i'd love to but i don't have much time for that right now. But i'll do that for sure in upcoming days.

@svoop
Copy link

svoop commented Jan 26, 2016

Great addition, too bad it stalled. 😢

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.

4 participants