I'm struggling with implementing more compact locale path on Forem.
In my experience whenever you'd leave the locale slot optional (like example.com/ => :en but example.com/fr/ => :fr), the software would misunderstand the second parameter as username. I'm looking for Rails config to work around this behavior but none have I found.
The url parameters are defined in routes.rb. So, you need to modify the routes to determine which parameter will refer to which value depending on your architecture. This might be confusing if you don't have such experience.
However, just modifying routes is not enough for all functions of Forem. You also need to follow the controllers and JavaScript functionalities to ensure everything works. You can write some tests to automatize this process.
Adding this kind of feature to Forem is a tricky task. So, we need to be careful and patient.
I have started to prepare a tutorial collection for dealing with custom forks of Forem, @leog. It'll also include adding new language supports. I want to inform you.
Yes, I'm exactly stuck at routes.rb. When the locale parameter is optional, the app seems sometimes to take what comes first as username or something that go to look up a nonexistent user like "fr". It prevents me from having a slick second level locale such as example.com/fr/....
Otherwise I have a virtually complete i18n setup covering both Rails and JS code. I cut corners on the JS part so it breaks a several tests but works great in production.
So a single-language instance can be easily deployed, but there is still a big obstacle to full m17n, which is injecting the locale parameter to every hardcoded link in tons of ERBs, otherwise they jump back to the default locale. (Sadly default_url_options only covers a tiny portion of their codebase...)
I'm struggling with implementing more compact locale path on Forem.
In my experience whenever you'd leave the locale slot optional (like example.com/ => :en but example.com/fr/ => :fr), the software would misunderstand the second parameter as username. I'm looking for Rails config to work around this behavior but none have I found.
Any suggestions are welcome.
The url parameters are defined in routes.rb. So, you need to modify the routes to determine which parameter will refer to which value depending on your architecture. This might be confusing if you don't have such experience.
You can follow the guide to learn the basic principles of Rails' routing mechanism: guides.rubyonrails.org/routing.html
However, just modifying routes is not enough for all functions of Forem. You also need to follow the controllers and JavaScript functionalities to ensure everything works. You can write some tests to automatize this process.
Adding this kind of feature to Forem is a tricky task. So, we need to be careful and patient.
I have started to prepare a tutorial collection for dealing with custom forks of Forem, @leog. It'll also include adding new language supports. I want to inform you.
Yes, I'm exactly stuck at routes.rb. When the locale parameter is optional, the app seems sometimes to take what comes first as username or something that go to look up a nonexistent user like "fr". It prevents me from having a slick second level locale such as
example.com/fr/...
.Otherwise I have a virtually complete i18n setup covering both Rails and JS code. I cut corners on the JS part so it breaks a several tests but works great in production.
So a single-language instance can be easily deployed, but there is still a big obstacle to full m17n, which is injecting the locale parameter to every hardcoded link in tons of ERBs, otherwise they jump back to the default locale. (Sadly
default_url_options
only covers a tiny portion of their codebase...)Thank you @ce7in, much appreciated!
Ok, I got it. I'll examine and modify the routes of your Forem fork, and try to determine if it works. Then, I'll send a pull request to your fork.
Oh thank you for your kind help! My routes.rb currently has a sort of second level locale but not functional.
Also, feel free to ask me when I can be of any help.