I see. But what if a spanish user wants to see english content? If
each piece of content is assigned a language why not just tag it
accordingly?
Tagging wouldn't need updating the models, filtering/showing language
specific content is still possible and it's actually DRY.

On Feb 6, 11:28 pm, Bruno Bornsztein <[email protected]>
wrote:
> @Alejandro,
> Sounds like a very clever solution ... I think it'd be cool to wrap this up
> into a plugin (with its own migrations to add the needed colums) so others
> could use it.
>
> @jak4 - he's adding the columns so he can record which locale each piece of
> content was created in. In theory, it might be enough to just check the
> locale of the user who created it, but this might not always be the same (an
> 'en' user might have created a blog post in 'es').
>
> Then, he can just show spanish content to spanish users, english to english
> users, etc.
>
> Nice work!
> bruno
>
> On Fri, Feb 6, 2009 at 3:19 PM, jak4 <[email protected]> wrote:
>
> > I don't see your point.
>
> > Why add it to so many models. What will this accomplish excactly? An
> > example would be helpful.
>
> > This is what I don't get
>
> > > My idea is that a user should see every piece of content in the
> > > language he has chosen.
>
> > regards
> >   jak4
>
> > On Feb 5, 5:19 pm, Alejandro <[email protected]> wrote:
> > > I'm just doing this. I added the localte to the models
> > > user,post,forum,activity and clipping. I also added the locale to the
> > > session.
> > > My idea is that a user should see every piece of content in the
> > > language he has chosen.
> > > The problem is getting the locale that lives in the session from the
> > > models when creating them. Also when finding them, because I wanted to
> > > override the find method of those entities to include the locale in
> > > every find invocation, to do that I used this:
>
> > >   def self.find(*args)
> > >     with_scope(:find=>{ :conditions=>"posts.language='#
> > > {UserInfo.current_locale}'" }) do
> > >       super(*args)
> > >     end
> > >   end
>
> > > I know I could just use the controllers to pass the locale, but I
> > > would have to look for every invocation to find, create and others and
> > > pass the locale. I prefer doing this in a more generic way.
>
> > > The workaround I found is creating a module (UserInfo) that stores the
> > > locale in the current thread:
>
> > > module UserInfo
> > >   def self.current_locale
> > >     Thread.current[:locale]
> > >   end
>
> > >   def self.current_locale=(locale)
> > >     Thread.current[:locale] = locale
> > >   end
> > > end
>
> > > the thing with this is that I need a web server that uses the same
> > > thread to handle all invocations of a user during his session.
> > > I've tried this solution with WEBrick and it works, but in production
> > > I use FASTCGI and I couldn't find any information of how it handles
> > > the session.
>
> > > Any help will be appreciated.
>
> > > On Jan 21, 3:16 pm, Bruno Bornsztein <[email protected]>
> > > wrote:
>
> > > > No, there isn't. You'd have to add it yourself, either by adding a
> > locale
> > > > column to user, or storing the users locale in the session.
>
> > > > On Wed, Jan 21, 2009 at 9:37 AM, jak4 <[email protected]>
> > wrote:
>
> > > > > Hi,
>
> > > > > is there already an mechanism to switch the language on-the-fly? Such
> > > > > as that the user can change his prefered language and doesn't need to
> > > > > logout/login again to see the new language?
>
> > > > > Best regards
> > > > >  Johannes
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CommunityEngine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/communityengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to