Hello, excuse me if this is a stupid question (I s...
# kobweb
u
Hello, excuse me if this is a stupid question (I started learning kotlin a year ago on android), and I am very interested in Kobweb, I would like to know if we can share its resources like with compose multiplatform and also can we create multilingual sites? Thanks a lot
s
afaik the new Compose Resources do not work with compose html, only the canvas target I believe - but I haven't looked into this. Speaking for String resources, libraries like Libres work fine with Kobweb. You can also use it to create multilingual sites, here's a post about this https://blog.fluen.se/tech/kobweb-localization. As for sharing the strings with other targets, I simply have a separate module with only Libres and depend on it in my kobweb and android/desktop modules.
for other resources like images I can't say much, but as long as it ends up in
resources/public
it should work for kobweb For other resources like images I can't say much, but as long as it ends up in
u
Thanks a lot, I found this on the jetbrains website: • Almost all resources are read synchronously in the caller thread. The only exceptions are raw files and all of the resources on the JS platform that are read asynchronously. https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-images-resources.html#setup It seems that it is supported, I will try
s
does it actually work? I only know that other users had issues with
LocalDensity
and with the fact that Kobweb doesn't pick up anything from
commonMain/composeResources
but rather needs you to copy them to
resources/public
as well
d
Kobweb does not support Compose Resources unfortunately. We plan to look into it eventually but it's not a priority. It may not be easily compatible with Compose HTML, especially starting with k2, as we are moving away from using the JB Compose plugin. You can read more about the current situation here: https://github.com/varabyte/kobweb/issues/486 Probably best to assume that Kobweb will always be quite a different target than most Compose targets.
Kobweb does not currently have an opinionated suggestion about how to do localization, it actually is a rather hard problem as different sites have wildly different approaches.
u
Thank you very much, I will check all that then 🙂
If I may ask, is there a way to create an RTL and LTR website?
s
sure, add
Modifier.dir(DirType.Rtl)
to you root surface composable. In the app template it should be this one https://github.com/varabyte/kobweb-templates/blob/7e42634cd72559fe737b53ba0bb76f9ee12691ab/app/default/site/src/site/AppEntry.kt.ftl#L35
👍 2
u
@S. Thanks a lot 🙂
a
> Hello, excuse me if this is a stupid question > I wouldn't call it that way, until now, most solutions are third party tools that might not work for all use-cases Try the following and see which one fit the project needs https://github.com/icerockdev/moko-resources https://github.com/kropp/kotlinx-gettext (https://victor.kropp.name/blog/kotlin-gettext-i18n/) https://github.com/comahe-de/i18n4k (https://comahe-de.github.io/i18n4k/) There are more kotlin multiplatform solutions