šŸ› Restore ability to change languages on-the-fly
authorDavid ā€˜Bombe’ Roden <bombe@pterodactylus.net>
Sun, 6 Jun 2021 09:13:13 +0000 (11:13 +0200)
committerDavid ā€˜Bombe’ Roden <bombe@pterodactylus.net>
Sun, 6 Jun 2021 09:13:13 +0000 (11:13 +0200)
commit642e558da0610f9a605fdef601d0572002577643
treec001cc263a477b9264bfc07233be0e9fb9dba1c0
parent58bb46435ed76f41df7b2ffd9a74fe5a4c1762d3
šŸ› Restore ability to change languages on-the-fly

Hieronymus (sone://-wFZ6ezwU3QgvM1u8~uiLbtjxSQ19tuqn4Q94lvTrwE) noticed that
changing the language in Fred’s web interface didn’t change Sone’s language
anymore.

Part of my (ongoing) restructuring of Sone’s source code is abstracting away
all the parts that are hard to test, i.e. every interaction with Freenet
itself and the translation mechanisms are a part of that. So when I introduced
a Translation object I completely forgot that it’s possible to change the
language during runtime.

Luckily that is easily solvable using a Supplier instead of the concrete
BaseL10n object. In theory that does have a performance impact (because now
there are at least two more function calls involved per translation) but I am
quite confident that the additional time actually used by this is far below
the 1-ms range so I am not worried about it.
src/main/kotlin/net/pterodactylus/sone/freenet/BaseL10nTranslation.kt
src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt
src/test/kotlin/net/pterodactylus/sone/freenet/BaseL10nTranslationTest.kt