Forem Creators and Builders

Discussion on: Standalone language fork

Collapse
ellativity profile image
Ella (she/her/elle)

Oooh, I think @ce7in was looking at doing something similar to this with French, maybe?

Also, @varhal has a Ukrainian Forem that is self-hosted and might have some advice!

Collapse
ce7in profile image
Muhammed Cetin • Edited on

Thanks, @ellativity.

Hi and welcome, @leog.

Yes, the thing that you want to do is possible.

For example, I have forked Forem to make some changes for a demo Q&A community (studyhab.com/), and have been using it for about 6 months. There are some challenges, but it is possible.

Now, I have been trying to add multi-language support to Forem like WPML or Polylang for WordPress. In this way, you will be able to add different posts, comments, pages, etc. for different languages.

The URL structure will be like that:

  • yoursite.com/an-english-post (This is for your base language. You can change it if you want.)
  • yoursite.com/es/a-spanish-version-of-the-post (This is your secondary language.)

If you set your main language as es, then your URL structure will be like that:

  • yoursite.com/a-spanish-version-of-the-post
  • yoursite.com/en/an-english-post

However, this will take some time. If you need a quick solution, you can add Spanish language support to your fork directly and can use it as your Forem image.

I have an important presentation to prepare, so I don't have enough time to explain it for now.

If you need some advice on how to do that, I can help you in 2 days.

Collapse
yheuhtozr profile image
yheuhtozr

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.

Thread Thread
ce7in profile image
Muhammed Cetin • Edited on

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.

Thread Thread
yheuhtozr profile image
yheuhtozr • Edited on

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...)

Thread Thread
leog profile image
Leo Giovanetti Author

Thank you @ce7in, much appreciated!

ce7in profile image
Muhammed Cetin

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.

Thread Thread
yheuhtozr profile image
yheuhtozr

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.

Collapse
leog profile image
Leo Giovanetti Author

Thank you very much @ellativity for bringing this to @ce7in’s attention. And thanks @ce7in for your help offer, it would be great, no rush at all.

I will most certainly go for just supporting Spanish without any other language, so hopefully that should simplify things a bit. I would need help with the changes to be done to be able to grab a fork as the source of the self host setup process, I’m guessing it involves publishing a container image with my changes to Docker Hub for example, to switch the forem container path to it.

Good luck on your presentation!

Thread Thread
ce7in profile image
Muhammed Cetin

I will most certainly go for just supporting Spanish without any other language

In that case, it will be easy for you.

Thread Thread
leog profile image
Leo Giovanetti Author

Hey @ce7in! Any update on the tutorial you were preparing?

Collapse
ellativity profile image
Ella (she/her/elle)

Thanks so much for responding so soon, @ce7in, and for being so helpful!

Good luck with your presentation!