Skip to main content


!Friendica Support

Mal wieder eine frage 😀

Years ago I did a bit of work on Drupal. Once of the slowdowns in their code is that there is a huge number of functions that needed to translate strings in a chosen language. This was a real pain in the A** to be honest, used a lot of cpu/memory.

These days servers are faster but when I look at the code I wonder if there should at least be a default language that does not need to be translated since it already has all the strings in the wanted language.

Why did friendica choose to do it this way too? Imho a small function and database tables per language would be a lot faster.

Curious about the choice. Anyone?

Friendica Support reshared this.

In the Drupal days I was able to bring down mem/cpu by some 30 percent. What they did was simply translate everything afaik. Even when it was xx to xx, not xx to yy
The American English and the British English translations aren't 100% which means that the translation file is slimmer as some base translation strings are used as is, but it shouldn't be that impactful nonetheless for CPU. For memory this is another can of worms.

From my experience it is good to have the translations in a database with some simple queries. So not t("a very long sentence with lots of chars", $lang); since it has a bad performance. I only looked at the code for now and it does look like Drupal a bit.

I think it is doable to find a better solution but that should only be done after xdebug sessions 😀

I can guarantee you that 80% of the page time is used by the database. If we used it for the translation, page load would be even slower. I have run the XDebug profile before and the translation wasn't even in the top ten most resource-intensive functions. In a typical /network call, the translation function DI::l10n()->t() is called around 1,500 times for a total processing time of 12ms. Meanwhile, there are about 150 SELECT database queries totaling 72ms.
I have a solution just for you: Completely remove the view/lang folder, and if you do, please tell me the performances gains in CPU/memory, I'm curious.
⇧