hey, i want my site in more than 1 language, ex english, dutch, frence, german. how must i accomplish this??? cuz i have always somehting like this def index =>> this is with the index.rhtml //some code end and depending on the language the user want an other rhtml must be loaded like def index_en ==>> index_en.rhtml def index_nl ==>> index_nl.rhtml => put the problem here is the code in the defs are the same :s:s:s isnt there another way to do this???
Nick Brutyn wrote:> hey, > > i want my site in more than 1 language, ex english, dutch, frence, german. > > how must i accomplish this??? > > cuz i have always somehting like this > > def index =>> this is with the index.rhtml > //some code > end > > and depending on the language the user want an other rhtml must be loaded > like > def index_en ==>> index_en.rhtml > def index_nl ==>> index_nl.rhtml > => put the problem here is the code in the defs are the same :s:s:s > > isnt there another way to do this???My own "Using Gettext To Translate Your Rails Application" might be of help: http://manuals.rubyonrails.com/read/chapter/105 Also, you might want to check Multilingual Rails. http://www.tuxsoft.se/sv/oss/rails/multilingual Also, there is preliminary support for l10n in Edge Rails, which is nice for starters. Lots of important stuff missing though. But good enough for 80% of the cases. Sascha Ebach
hey, thanks for the info, i am pretty new at this. i dont quite understand this http://manuals.rubyonrails.com/read/chapter/105 do u have a working example of some sort??? thanks in advance>From: Sascha Ebach <se-eFwX6J65rk9VioaHkBSlcw02NpfuEekPhC4ANOJQIlc@public.gmane.org> >Reply-To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >Subject: Re: [Rails] Multi languages in rails >Date: Mon, 31 Oct 2005 12:49:13 +0100 > >Nick Brutyn wrote: >>hey, >> >>i want my site in more than 1 language, ex english, dutch, frence, german. >> >>how must i accomplish this??? >> >>cuz i have always somehting like this >> >>def index =>> this is with the index.rhtml >>//some code >>end >> >>and depending on the language the user want an other rhtml must be loaded >>like >>def index_en ==>> index_en.rhtml >>def index_nl ==>> index_nl.rhtml >>=> put the problem here is the code in the defs are the same :s:s:s >> >>isnt there another way to do this??? > >My own "Using Gettext To Translate Your Rails Application" might be of >help: http://manuals.rubyonrails.com/read/chapter/105 > >Also, you might want to check Multilingual Rails. >http://www.tuxsoft.se/sv/oss/rails/multilingual > >Also, there is preliminary support for l10n in Edge Rails, which is nice >for starters. Lots of important stuff missing though. But good enough for >80% of the cases. > >Sascha Ebach >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails
Hi Nick,> hey, thanks for the info, i am pretty new at this. > > i dont quite understand this > http://manuals.rubyonrails.com/read/chapter/105 > > do u have a working example of some sort???you would have to be more specific about that. The guide is pretty much a step-by-step thing. What is it that you don''t understand? A sample can be found in the Ruby-Gettext Package. Just have a look at it. Sascha
On 31-Oct-05, at 3:49 AM, Sascha Ebach wrote:> Also, there is preliminary support for l10n in Edge Rails, which is > nice for starters. Lots of important stuff missing though. But good > enough for 80% of the cases.Where can I read more about this preliminary support? Thanks, Peter
Peter Michaux wrote:> > On 31-Oct-05, at 3:49 AM, Sascha Ebach wrote: > >> Also, there is preliminary support for l10n in Edge Rails, which is >> nice for starters. Lots of important stuff missing though. But good >> enough for 80% of the cases. > > > Where can I read more about this preliminary support?Use the source, Luke. http://dev.rubyonrails.org/browser/plugins/localization I subscribe to the commit log, so I am always current with the news. Sascha
dmarko-KxaEA3z1jV+iEHBPiYQIQwC/G2K4zDHf@public.gmane.org
2005-Nov-01 08:49 UTC
Re: Multi languages in rails
I would like to ask about http://dev.rubyonrails.org/browser/plugins/localization plugin. I have read documentation but havent found any info on how to change language preference per user/request. Default language is stored in Controller but how to change it per user? Thanks for any hint, David Marko Sascha Ebach <se-eFwX6J65rk9VioaHkBSlcw02NpfuEekPhC4ANOJQIlc@public.gmane.org> Sent by: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org 31.10.2005 22:00 Please respond to rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org To rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org cc Subject Re: [Rails] Multi languages in rails Peter Michaux wrote:> > On 31-Oct-05, at 3:49 AM, Sascha Ebach wrote: > >> Also, there is preliminary support for l10n in Edge Rails, which is >> nice for starters. Lots of important stuff missing though. But good >> enough for 80% of the cases. > > > Where can I read more about this preliminary support?Use the source, Luke. http://dev.rubyonrails.org/browser/plugins/localization I subscribe to the commit log, so I am always current with the news. Sascha _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
> My own "Using Gettext To Translate Your Rails Application" might be of > help: http://manuals.rubyonrails.com/read/chapter/105Great for the code part with subpart of text, a pain in the ass for large pages without code. You wouldn''t want to use gettext to translate a full book, as much as you wouldn''t want to use it to translate your pages.
Fabien Penso wrote:>>My own "Using Gettext To Translate Your Rails Application" might be of >>help: http://manuals.rubyonrails.com/read/chapter/105 > > > Great for the code part with subpart of text, a pain in the ass for > large pages without code. > > You wouldn''t want to use gettext to translate a full book, as much as > you wouldn''t want to use it to translate your pages.You are absolutely right, and I think this is what I am also saying in the manual. For complete pages of text you might want to include different templates based on requested language. With a lot of text your translation work will most likely be non-automated. Which is a fancy way of saying "You will have to do it all be hand". Sascha Ebach
> For complete pages of text you might want to include > different templates based on requested language. With a lot of text your > translation work will most likely be non-automated. Which is a fancy way > of saying "You will have to do it all be hand".That''s why I''d like to have it all automated. I posted ideas on the list without any feedbacks. We want multilanguages pages, stored in a way than Apache/Multiviews can handle them (so we still can serve static pages), and we don''t want to write a single line of code for that purpose. 1. Views files could be named views/action.en.rhtml, views/action.fr.rhtml, etc. 2. You could call urls with domain.com/controller/action.en.html to force rails to use that specific languages for the views. 3. Rails would choose the language based on the url, then if not specified to the browser header languages. If nothing has been supplied, we would use the default language defined in the rails environment. I see only benefits of such a way to handle multi languages websites. I''ll implement it for myself at least.
Fabien Penso wrote:>>For complete pages of text you might want to include >>different templates based on requested language. With a lot of text your >>translation work will most likely be non-automated. Which is a fancy way >>of saying "You will have to do it all be hand". > > > That''s why I''d like to have it all automated. > > I posted ideas on the list without any feedbacks. > > We want multilanguages pages, stored in a way than Apache/Multiviews > can handle them (so we still can serve static pages), and we don''t > want to write a single line of code for that purpose. > > 1. Views files could be named views/action.en.rhtml, views/action.fr.rhtml, etc. > > 2. You could call urls with domain.com/controller/action.en.html to > force rails to use that specific languages for the views. > > 3. Rails would choose the language based on the url, then if not > specified to the browser header languages. If nothing has been > supplied, we would use the default language defined in the rails > environment. > > I see only benefits of such a way to handle multi languages websites. > I''ll implement it for myself at least.This should be fairly simple to do in your controller, maybe a two- or three-liner. Also I don''t think it is very wise to rely on Apache-specific behaviour when you can just do it in your controller. Also, you might want to check out Mulitlingual Rails which already does something similiar to what you are suggesting. http://www.tuxsoft.se/sv/oss/rails/multilingual Sascha
> This should be fairly simple to do in your controller, maybe a two- or > three-liner. Also I don''t think it is very wise to rely on > Apache-specific behaviour when you can just do it in your controller.Yes you do because you want to still be able to use caches_page and the multi language system to work under your httpd when serving static pages.> Also, you might want to check out Mulitlingual Rails which already does > something similiar to what you are suggesting. > > http://www.tuxsoft.se/sv/oss/rails/multilingualIt does a little (finding the right view file) but I don''t think it handles the serving of different language depending of the language submit through the browser header.
I''ve read your ideas with interest (I''m in the early stage of implementing an i18n and l10n rails site (r7e)). I have to say that I like the Gettext approach better (only my opinion though). Creating as many pages as languages in your system is also a pain in the ass and hardly possible when your site have to handle 50 different languages (it''s not my case but to generalize an approach you should also think about these cases). I''d like much more to have a sort of ''key'' in my page that would be automatically translated to the right string depending on the user''s language. What do you think? Matthieu Riou. On 11/2/05, Fabien Penso <fabienpenso-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > For complete pages of text you might want to include > > different templates based on requested language. With a lot of text your > > translation work will most likely be non-automated. Which is a fancy way > > of saying "You will have to do it all be hand". > > That''s why I''d like to have it all automated. > > I posted ideas on the list without any feedbacks. > > We want multilanguages pages, stored in a way than Apache/Multiviews > can handle them (so we still can serve static pages), and we don''t > want to write a single line of code for that purpose. > > 1. Views files could be named views/action.en.rhtml, > views/action.fr.rhtml, etc. > > 2. You could call urls with domain.com/controller/action.en.html<http://domain.com/controller/action.en.html>to > force rails to use that specific languages for the views. > > 3. Rails would choose the language based on the url, then if not > specified to the browser header languages. If nothing has been > supplied, we would use the default language defined in the rails > environment. > > I see only benefits of such a way to handle multi languages websites. > I''ll implement it for myself at least. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 11/2/05, Matthieu Riou <matthieu.riou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve read your ideas with interest (I''m in the early stage of implementing > an i18n and l10n rails site (r7e)). I have to say that I like the Gettext > approach better (only my opinion though). Creating as many pages as > languages in your system is also a pain in the ass and hardly possible when > your site have to handle 50 different languages (it''s not my case but to > generalize an approach you should also think about these cases). > > I''d like much more to have a sort of ''key'' in my page that would be > automatically translated to the right string depending on the user''s > language. What do you think?Both approach are fine. Gettext is ok for text included in code part of the site, or short sentences. But if you want to translate that : http://templeet.org/ which includes lots of text and no code (that''s an example), it''s _much_ easier to copy the view file and translate it completly.
On 2-nov-2005, at 8:22, Fabien Penso wrote:>> This should be fairly simple to do in your controller, maybe a >> two- or >> three-liner. Also I don''t think it is very wise to rely on >> Apache-specific behaviour when you can just do it in your controller. > > Yes you do because you want to still be able to use caches_page and > the multi language system to work under your httpd when serving static > pages. > >> Also, you might want to check out Mulitlingual Rails which already >> does >> something similiar to what you are suggesting. >> >> http://www.tuxsoft.se/sv/oss/rails/multilingual > > It does a little (finding the right view file) but I don''t think it > handles the serving of different language depending of the language > submit through the browser header.It''s not very difficult to implement this yourself. -- Julian "Julik" Tarkhanov
> http://templeet.org/ > > which includes lots of text and no code (that''s an example), it''s > _much_ easier to copy the view file and translate it completly.Yes, you are right. I think in the case of templeet.org you might want to build a translation system around those static pages. I imagine something like this: You would fetch your pages with an URL like this: /page/language/name-of-page-or-id (or the other way around ) for example /page/en/download /page/fr/download ... or /page/download (defaults to en) /page/download/en /page/download/fr Than create a dynamic rule in your routes.rb. app/controllers/page.rb: class Page def whatever # fetch page of whatever language is passed end end Sorry for not being more specific. I am a little time pressed today. Sascha
On 11/2/05, Sascha Ebach <se-eFwX6J65rk9VioaHkBSlcw02NpfuEekPhC4ANOJQIlc@public.gmane.org> wrote:> > http://templeet.org/(...)> You would fetch your pages with an URL like this: > > /page/language/name-of-page-or-id (or the other way around ) > for example > /page/en/download > /page/fr/download > ... > or > /page/download (defaults to en) > /page/download/en > /page/download/frSure, I could do it myself. I just mean it should be included by default into rails because many people will need such a system, and it''s not very difficult to implement. I guess I''ll do my own. About your idea. Sure it will work, but then I won''t be able to use caches_page, still deliver _static_ pages through Apache and have the language detection working. (apache/multiviews will search for .en.html .fr.html etc but maybe this could be tuned to search for page/en/page.html etc).
Fabien Penso wrote:> Sure, I could do it myself. I just mean it should be included by > default into rails because many people will need such a system, and > it''s not very difficult to implement. I guess I''ll do my own.I get your sentiment. L10n is just starting to get implemented in Rails because it is not of massive importance to the core team. Otherwise we would have seen support for it long ago. So, something like this will eventually find its way into Rails, we just have to be a little more patient. I am guessing before 1.5.> About your idea. Sure it will work, but then I won''t be able to use > caches_page, still deliver _static_ pages through Apache and have the > language detection working. (apache/multiviews will search for > .en.html .fr.html etc but maybe this could be tuned to search for > page/en/page.html etc).I don''t know enough about Apache multiviews. I would probably try to to caching in Rails. I wouldn''t want that much logic in the webserver. This has bitten me before. What if you decide to upgrade to lighttpd tommorow? It will only make it more difficult. Just me 2c Sascha
On 11/2/05, Matthieu Riou <matthieu.riou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve read your ideas with interest (I''m in the early stage of implementing > an i18n and l10n rails site (r7e)).What are l10n and r7e?> Matthieu Riou.Sincerely, Tom Lieber tom-V0YqjHVuocLQT0dZR+AlfA@public.gmane.org http://AllTom.com/
l10n stands for localization (or localisation depending where you come from) and r7e was a very bad pun to shorten "rails site". Shame on me :) Cheers, Matthieu. On 11/2/05, Tom Lieber <alltom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 11/2/05, Matthieu Riou <matthieu.riou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''ve read your ideas with interest (I''m in the early stage of > implementing > > an i18n and l10n rails site (r7e)). > > What are l10n and r7e? > > > Matthieu Riou. > > Sincerely, > > Tom Lieber > tom-V0YqjHVuocLQT0dZR+AlfA@public.gmane.org > http://AllTom.com/ > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails