I'm trying to get Gitorious up and running using Rails 3, but I've come a cross a problem.
I've this line in the view.
<p><%= t("views.commits.message").call(self, tree_path(@commit.id)) %></p>
The corresponding locales line looks like this [config/locales/en.rb
]
:message => lambda { |this, path| "This is the initial commit in this repository, " +
this.link_to( "browse the initial tree state", path ) + "." }
The problem here is that the lambda method isn't being called using #call
in the view, it's being called by someone else, which means that this
isn't self
that is being passed to it.
this
contains views.commits.message
and path
contains {:rescue_format=>:html}
.
The Gitorious team has used this approach all over the application, which means that I can't just move the logic into a helper method without taking a day of form work.
I did some research and found this thread about the exact line.
This was the answare to the problem.
This seems to indicate you have the i18n gem installed on your system; this gem is incompatible with Gitorious. Uninstalling it with Rubygems should resolve the issue.
I've tried to uninstall i18n
, but running bundle install
just installs it again.
How should I solve this problem without refactor the 700 line locales file?
This is a common problem, how to break up complex nested pieces of text.
Using markdown to simplify it
Perhaps in Chinese you'd instead say
We have to consider 3 things;
If the position of the link relative to the text doesnt need to change, then @WattsInABox correct.
We then just compose
But sometimes the order and position does matter, in which case we can try to be more clever.
Then we can interpolate the link in the right place