Forem Creators and Builders 🌱

Leo Giovanetti
Leo Giovanetti

Posted on

Standalone language fork

I love Forem. And I'm not just saying that because this is my first post in this great community. It's such a well thought tool for the mind and the collective knowledge.

So, of course, I wanted to create my own self-hosted instance for an entire community that I believe needs a place like Forem to share its knowledge. But, and it's a big but, that community speaks Spanish natively. And there is no Spanish translation of Forem, yet.

So I figured, as there is no open contributions to expand the languages supported by the tool, I was thinking I could potentially fork the repository, add Spanish and translating all the string myself, and point the self-hosted ansible playbook to use a custom container with my forked version of Forem with Spanish. But, is that even possible? If so, I would gladly expand this post with instructions to achieve it while I dig deeper and get help to do it. But wanted to check first to avoid being out on a limb at later stages of my little experiment.

What do you think?

Top comments (15)

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

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

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

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

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

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

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!

Collapse
 
dinozavrix profile image
dinozavrix

Hi all! It's good to hear that forem is becoming more and more international. Looking forward to full multilingual support one day!

We are currently updating the translation for ux.pub by changing the locale files and the new updates do not work. After overwriting the yml files, the site looks completely broken, as if all the translation files are missing. Could you please advise:

  1. An easy way to check all yml files
  2. How to view forem errors when parsing locales yml files

Thank you!

Collapse
 
paulvu profile image
Paul Vu

I'm going to build a Forem for only one local language. I want to make sure is work?

  1. Create a new fork
  2. Translate all file at here github.com/forem/forem/tree/main/c...
  3. Redeploy.

Is it right?
Thank you for building Forem.

Collapse
 
platoalt profile image
anTonys

intreasting post