diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/StringResourceCache.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/StringResourceCache.kt index 9f2697d538..509b53c6c0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/StringResourceCache.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/StringResourceCache.kt @@ -30,6 +30,10 @@ import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.lifecycle.compose.LifecycleResumeEffect +import org.jetbrains.compose.resources.PluralStringResource +import org.jetbrains.compose.resources.StringResource +import com.vitorpamplona.amethyst.commons.ui.pluralStringRes as commonsPluralStringRes +import com.vitorpamplona.amethyst.commons.ui.stringRes as commonsStringRes /** * Cache for stringResource because it seems to be > 1ms function in some phones @@ -73,6 +77,28 @@ fun StringResSetup() { @Composable fun stringRes(id: Int): String = resourceCache.get(id) ?: stringResource(id).also { resourceCache.put(id, it) } +// Overloads for keys already migrated to commons Compose resources +// (com.vitorpamplona.amethyst.commons.resources.Res.string.*). They let a file +// mix migrated and unmigrated keys under this one import — overload resolution +// picks by argument type — so migrating a key is just R.string.x -> Res.string.x. +// When a whole file moves to commons, swap this import for +// com.vitorpamplona.amethyst.commons.ui.stringRes. +@Composable +fun stringRes(id: StringResource): String = commonsStringRes(id) + +@Composable +fun stringRes( + id: StringResource, + vararg args: Any, +): String = commonsStringRes(id, *args) + +@Composable +fun pluralStringRes( + id: PluralStringResource, + count: Int, + vararg args: Any, +): String = if (args.isEmpty()) commonsPluralStringRes(id, count) else commonsPluralStringRes(id, count, *args) + @Composable fun stringRes( id: Int, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/ChatHeaderLayout.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/ChatHeaderLayout.kt index ab1b69fd10..74af9b38b9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/ChatHeaderLayout.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/ChatHeaderLayout.kt @@ -40,6 +40,8 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.R +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.profile_banner import com.vitorpamplona.amethyst.ui.layouts.listItem.SlimListItem import com.vitorpamplona.amethyst.ui.note.elements.TimeAgo import com.vitorpamplona.amethyst.ui.painterRes @@ -64,7 +66,7 @@ fun ChannelNamePreview() { channelPicture = { Image( painter = painterRes(R.drawable.github, 1), - contentDescription = stringRes(id = R.string.profile_banner), + contentDescription = stringRes(id = Res.string.profile_banner), contentScale = ContentScale.FillWidth, ) }, @@ -98,7 +100,7 @@ fun ChannelNamePreview() { leadingContent = { Image( painter = painterRes(R.drawable.github, 2), - contentDescription = stringRes(id = R.string.profile_banner), + contentDescription = stringRes(id = Res.string.profile_banner), contentScale = ContentScale.FillWidth, modifier = Size55Modifier, ) @@ -123,7 +125,7 @@ fun ChannelNamePreview() { leadingContent = { Image( painter = painterRes(R.drawable.github, 2), - contentDescription = stringRes(id = R.string.profile_banner), + contentDescription = stringRes(id = Res.string.profile_banner), contentScale = ContentScale.FillWidth, modifier = Size55Modifier, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/LeftPictureLayout.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/LeftPictureLayout.kt index 389ebd06ee..c92ddca773 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/LeftPictureLayout.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/LeftPictureLayout.kt @@ -41,6 +41,8 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.sp import com.vitorpamplona.amethyst.R +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.profile_banner import com.vitorpamplona.amethyst.ui.note.LikeIcon import com.vitorpamplona.amethyst.ui.note.TextCount import com.vitorpamplona.amethyst.ui.note.ZappedIcon @@ -66,7 +68,7 @@ fun LeftPictureLayoutPreviewCard() { onImage = { Image( painter = painterRes(R.drawable.github, 3), - contentDescription = stringRes(id = R.string.profile_banner), + contentDescription = stringRes(id = Res.string.profile_banner), contentScale = ContentScale.FillWidth, modifier = Modifier.fillMaxSize().clip(QuoteBorder), ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/listItem/SlimListItemLayout.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/listItem/SlimListItemLayout.kt index 269095c8c2..e47946e927 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/listItem/SlimListItemLayout.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/listItem/SlimListItemLayout.kt @@ -63,6 +63,8 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.offset import androidx.compose.ui.unit.sp import com.vitorpamplona.amethyst.R +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.profile_banner import com.vitorpamplona.amethyst.ui.layouts.ChatHeaderLayout import com.vitorpamplona.amethyst.ui.layouts.listItem.ListTokens.ListItemContainerElevation import com.vitorpamplona.amethyst.ui.note.elements.TimeAgo @@ -92,7 +94,7 @@ fun ChannelNamePreview() { channelPicture = { Image( painter = painterRes(R.drawable.github, 1), - contentDescription = stringRes(id = R.string.profile_banner), + contentDescription = stringRes(id = Res.string.profile_banner), contentScale = ContentScale.FillWidth, ) }, @@ -126,7 +128,7 @@ fun ChannelNamePreview() { leadingContent = { Image( painter = painterRes(R.drawable.github, 2), - contentDescription = stringRes(id = R.string.profile_banner), + contentDescription = stringRes(id = Res.string.profile_banner), contentScale = ContentScale.FillWidth, modifier = Size55Modifier, ) @@ -152,7 +154,7 @@ fun ChannelNamePreview() { leadingContent = { Image( painter = painterRes(R.drawable.github, 2), - contentDescription = stringRes(id = R.string.profile_banner), + contentDescription = stringRes(id = Res.string.profile_banner), contentScale = ContentScale.FillWidth, modifier = Size55Modifier, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerContent.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerContent.kt index 0b092328f8..9e82beb8a9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerContent.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerContent.kt @@ -75,7 +75,6 @@ import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalFocusManager -import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.LinkAnnotation import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.font.FontWeight @@ -96,6 +95,8 @@ import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbol import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.ImmutableListOfLists import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.profile_banner import com.vitorpamplona.amethyst.commons.scheduledposts.ScheduledPostStatus import com.vitorpamplona.amethyst.isDebug import com.vitorpamplona.amethyst.model.Account @@ -278,7 +279,7 @@ fun ProfileContentTemplate( } else { AsyncImage( model = R.drawable.profile_banner, - contentDescription = stringResource(R.string.profile_banner), + contentDescription = stringRes(Res.string.profile_banner), contentScale = ContentScale.Crop, modifier = bannerModifier, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DefaultImageHeader.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DefaultImageHeader.kt index 6a91836f0a..6b6dda6959 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DefaultImageHeader.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DefaultImageHeader.kt @@ -31,6 +31,8 @@ import androidx.compose.ui.layout.ContentScale import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.profile_banner import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserBanner import com.vitorpamplona.amethyst.ui.components.MyAsyncImage import com.vitorpamplona.amethyst.ui.note.BaseUserPicture @@ -143,7 +145,7 @@ fun DefaultProfileBanner( ) { Image( painter = painterRes(R.drawable.profile_banner, sizeReference), - contentDescription = stringRes(R.string.profile_banner), + contentDescription = stringRes(Res.string.profile_banner), contentScale = ContentScale.Crop, modifier = modifier, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/AppDefinition.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/AppDefinition.kt index d0a8802b43..daac9399c7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/AppDefinition.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/AppDefinition.kt @@ -81,6 +81,8 @@ import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.model.EmptyTagList import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.toImmutableListOfLists +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.profile_banner import com.vitorpamplona.amethyst.commons.richtext.RichTextParser import com.vitorpamplona.amethyst.commons.ui.components.ClickableTextPrimary import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNote @@ -175,7 +177,7 @@ fun RenderAppDefinition( } else { Image( painter = painterRes(R.drawable.profile_banner, 6), - contentDescription = stringRes(id = R.string.profile_banner), + contentDescription = stringRes(id = Res.string.profile_banner), contentScale = ContentScale.FillWidth, modifier = Modifier diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DrawBanner.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DrawBanner.kt index 9ca9252968..206deedc85 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DrawBanner.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DrawBanner.kt @@ -41,6 +41,8 @@ import androidx.compose.ui.unit.dp import coil3.compose.AsyncImage import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.profile_banner import com.vitorpamplona.amethyst.commons.richtext.RichTextParser import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserBanner import com.vitorpamplona.amethyst.ui.components.ZoomableImageDialog @@ -105,7 +107,7 @@ fun DrawBanner( } else { Image( painter = painterRes(R.drawable.profile_banner, 2), - contentDescription = stringRes(id = R.string.profile_banner), + contentDescription = stringRes(id = Res.string.profile_banner), contentScale = ContentScale.FillWidth, modifier = Modifier diff --git a/amethyst/src/main/res/values-ar-rSA/strings.xml b/amethyst/src/main/res/values-ar-rSA/strings.xml index 8e68e566fe..56dbf0f87c 100644 --- a/amethyst/src/main/res/values-ar-rSA/strings.xml +++ b/amethyst/src/main/res/values-ar-rSA/strings.xml @@ -99,7 +99,6 @@ إضافة "الرد على" " و " - لافتة الملف الشخصي خطأ أثناء تحليل رسالة الخطأ "المتابعون" "متابِعاً" diff --git a/amethyst/src/main/res/values-bn-rBD/strings.xml b/amethyst/src/main/res/values-bn-rBD/strings.xml index b08bb0658d..b54304ddda 100644 --- a/amethyst/src/main/res/values-bn-rBD/strings.xml +++ b/amethyst/src/main/res/values-bn-rBD/strings.xml @@ -88,7 +88,6 @@ যুক্ত করুন "এই ব্যক্তির প্রতিউত্তর দিচ্ছেন " " এবং " - প্রোফাইলের ব্যানার ত্রুটি বার্তা পার্স করতে ব্যর্থ " অনুসরণ" " অনুসারী" diff --git a/amethyst/src/main/res/values-cs/strings.xml b/amethyst/src/main/res/values-cs/strings.xml index 61c3ffc41e..22d9f8acf8 100644 --- a/amethyst/src/main/res/values-cs/strings.xml +++ b/amethyst/src/main/res/values-cs/strings.xml @@ -105,7 +105,6 @@ Přidat "odpovídá na " " a " - Banner profilu Chyba při zpracování chybové zprávy " Sleduje" " Sledující" diff --git a/amethyst/src/main/res/values-de-rDE/strings.xml b/amethyst/src/main/res/values-de-rDE/strings.xml index cd60806edf..d8228380c0 100644 --- a/amethyst/src/main/res/values-de-rDE/strings.xml +++ b/amethyst/src/main/res/values-de-rDE/strings.xml @@ -97,7 +97,6 @@ Hinzufügen "Antworten auf " " und " - Profilbanner Fehler beim Parsen der Fehlermeldung " Gefolgt" " Follower" diff --git a/amethyst/src/main/res/values-de/strings.xml b/amethyst/src/main/res/values-de/strings.xml index ed457e0083..dc9401c640 100644 --- a/amethyst/src/main/res/values-de/strings.xml +++ b/amethyst/src/main/res/values-de/strings.xml @@ -59,7 +59,6 @@ Hinzufügen "Antworten auf " " und " - Profilbanner Fehler beim Parsen der Fehlermeldung " Folgen" " Anhänger" diff --git a/amethyst/src/main/res/values-el-rGR/strings.xml b/amethyst/src/main/res/values-el-rGR/strings.xml index 85eea16ff4..80546eb122 100644 --- a/amethyst/src/main/res/values-el-rGR/strings.xml +++ b/amethyst/src/main/res/values-el-rGR/strings.xml @@ -85,7 +85,6 @@ Προσθήκη "απάντηση σε " " και " - Ταπετσαρία Προφίλ Σφάλμα ανάλυσης σφάλμα μηνύματος " Ακολουθείτε" " Ακόλουθοι" diff --git a/amethyst/src/main/res/values-eo-rUY/strings.xml b/amethyst/src/main/res/values-eo-rUY/strings.xml index dcd102907d..d9aaaa44b6 100644 --- a/amethyst/src/main/res/values-eo-rUY/strings.xml +++ b/amethyst/src/main/res/values-eo-rUY/strings.xml @@ -86,7 +86,6 @@ Aldoni "respondante al " " kaj " - Profila Murpapero Eraro analizante de erara mesaĝo " Sekvanti" " Sekvantoj" diff --git a/amethyst/src/main/res/values-eo/strings.xml b/amethyst/src/main/res/values-eo/strings.xml index 601a7699d8..0d7908fe66 100644 --- a/amethyst/src/main/res/values-eo/strings.xml +++ b/amethyst/src/main/res/values-eo/strings.xml @@ -41,7 +41,6 @@ Aldoni "respondante al " " kaj " - Profila Murpapero Eraro analizante de erara mesaĝo " Sekvanti" " Sekvantoj" diff --git a/amethyst/src/main/res/values-es-rES/strings.xml b/amethyst/src/main/res/values-es-rES/strings.xml index 4a8cefe2ce..5407d68d44 100644 --- a/amethyst/src/main/res/values-es-rES/strings.xml +++ b/amethyst/src/main/res/values-es-rES/strings.xml @@ -88,7 +88,6 @@ Añadir "respondiendo a " " y " - Banner de perfil Error al analizar el mensaje de error " Siguiendo" " Seguidores" diff --git a/amethyst/src/main/res/values-es-rMX/strings.xml b/amethyst/src/main/res/values-es-rMX/strings.xml index ed08c67bdd..2df9849b56 100644 --- a/amethyst/src/main/res/values-es-rMX/strings.xml +++ b/amethyst/src/main/res/values-es-rMX/strings.xml @@ -88,7 +88,6 @@ Agregar "respondiendo a " " y " - Banner del perfil Error al analizar el mensaje de error " Siguiendo" " Seguidores" diff --git a/amethyst/src/main/res/values-es-rUS/strings.xml b/amethyst/src/main/res/values-es-rUS/strings.xml index a7c696fcd6..386502a9b1 100644 --- a/amethyst/src/main/res/values-es-rUS/strings.xml +++ b/amethyst/src/main/res/values-es-rUS/strings.xml @@ -88,7 +88,6 @@ Agregar "respondiendo a " " y " - Banner del perfil Error al analizar el mensaje de error " Siguiendo" " Seguidores" diff --git a/amethyst/src/main/res/values-es/strings.xml b/amethyst/src/main/res/values-es/strings.xml index b60ed146ee..ac2c7ef231 100644 --- a/amethyst/src/main/res/values-es/strings.xml +++ b/amethyst/src/main/res/values-es/strings.xml @@ -49,7 +49,6 @@ Añadir "respondiendo a " " y " - Banner de perfil " Siguiendo" " Seguidores" Perfil diff --git a/amethyst/src/main/res/values-fa-rIR/strings.xml b/amethyst/src/main/res/values-fa-rIR/strings.xml index 533f82f463..cad42e827a 100644 --- a/amethyst/src/main/res/values-fa-rIR/strings.xml +++ b/amethyst/src/main/res/values-fa-rIR/strings.xml @@ -88,7 +88,6 @@ افزودن " پاسخ به" " و " - بنر پروفایل خطا در تفسیر پیغام خطا "دنبال شونده" "دنبال کننده" diff --git a/amethyst/src/main/res/values-fa/strings.xml b/amethyst/src/main/res/values-fa/strings.xml index b20114a2e4..5b6b0e7123 100644 --- a/amethyst/src/main/res/values-fa/strings.xml +++ b/amethyst/src/main/res/values-fa/strings.xml @@ -58,7 +58,6 @@ افزودن " پاسخ به" " و " - بنر پروفایل خطا در تفسیر پیغام خطا "دنبال شونده" "دنبال کننده" diff --git a/amethyst/src/main/res/values-fi-rFI/strings.xml b/amethyst/src/main/res/values-fi-rFI/strings.xml index dec0945e53..05626a5fa8 100644 --- a/amethyst/src/main/res/values-fi-rFI/strings.xml +++ b/amethyst/src/main/res/values-fi-rFI/strings.xml @@ -87,7 +87,6 @@ Lisää "vastaus kohteeseen " " ja " - Profiilin banneri Virhe virhesanomaa tulkittaessa " Seuratut" " Seuraajat" diff --git a/amethyst/src/main/res/values-fr-rCA/strings.xml b/amethyst/src/main/res/values-fr-rCA/strings.xml index 279dda591d..1aebd97a6d 100644 --- a/amethyst/src/main/res/values-fr-rCA/strings.xml +++ b/amethyst/src/main/res/values-fr-rCA/strings.xml @@ -81,7 +81,6 @@ Ajouter "répondre à " " et " - Bannière du profil Erreur d\'analyse du message d\'erreur " Abonnements" " Abonnés" diff --git a/amethyst/src/main/res/values-fr-rFR/strings.xml b/amethyst/src/main/res/values-fr-rFR/strings.xml index e108548dd3..1f04651170 100644 --- a/amethyst/src/main/res/values-fr-rFR/strings.xml +++ b/amethyst/src/main/res/values-fr-rFR/strings.xml @@ -88,7 +88,6 @@ Ajouter "répondre à " " et " - Bannière du profil Erreur d\'analyse du message d\'erreur " Abonnements" " Abonnés" diff --git a/amethyst/src/main/res/values-fr/strings.xml b/amethyst/src/main/res/values-fr/strings.xml index b5faa5b054..d04f6f7089 100644 --- a/amethyst/src/main/res/values-fr/strings.xml +++ b/amethyst/src/main/res/values-fr/strings.xml @@ -59,7 +59,6 @@ Ajouter "répondre à " " et " - Bannière du profil Erreur d\'analyse du message d\'erreur " Abonnements" " Abonnés" diff --git a/amethyst/src/main/res/values-hi-rIN/strings.xml b/amethyst/src/main/res/values-hi-rIN/strings.xml index 09401bd513..f2789e5018 100644 --- a/amethyst/src/main/res/values-hi-rIN/strings.xml +++ b/amethyst/src/main/res/values-hi-rIN/strings.xml @@ -97,7 +97,6 @@ जोडें "उत्तर इनको " " तथा " - परिचय ध्वजचित्र अपक्रम संदेश परखने में अपक्रम " का अनुचरण" " अनुचर" diff --git a/amethyst/src/main/res/values-hu-rHU/strings.xml b/amethyst/src/main/res/values-hu-rHU/strings.xml index 1c712c64a9..7492b5edad 100644 --- a/amethyst/src/main/res/values-hu-rHU/strings.xml +++ b/amethyst/src/main/res/values-hu-rHU/strings.xml @@ -97,7 +97,6 @@ Hozzáadás "válasz erre: " " és " - Profilplakát Hiba a hibaüzenet elemzésekor " Követett" " Követő" diff --git a/amethyst/src/main/res/values-in-rID/strings.xml b/amethyst/src/main/res/values-in-rID/strings.xml index bf09bfe3eb..ddbb15f3cb 100644 --- a/amethyst/src/main/res/values-in-rID/strings.xml +++ b/amethyst/src/main/res/values-in-rID/strings.xml @@ -80,7 +80,6 @@ Tambah "balas ke " " dan " - Banner Profil Salah memilah pesan error " Mengikuti" " Pengikut" diff --git a/amethyst/src/main/res/values-in/strings.xml b/amethyst/src/main/res/values-in/strings.xml index 409bd78978..559818215c 100644 --- a/amethyst/src/main/res/values-in/strings.xml +++ b/amethyst/src/main/res/values-in/strings.xml @@ -41,7 +41,6 @@ Tambah "membalas kepada " " dan " - Spanduk Profil Gagal menguraikan pesan kesalahan " Mengikuti" " Pengikut" diff --git a/amethyst/src/main/res/values-it-rIT/strings.xml b/amethyst/src/main/res/values-it-rIT/strings.xml index b9376b8fe4..b544028b4f 100644 --- a/amethyst/src/main/res/values-it-rIT/strings.xml +++ b/amethyst/src/main/res/values-it-rIT/strings.xml @@ -84,7 +84,6 @@ Aggiungi "rispondendo a" " e " - Immagine di copertina Errore analisi messaggio d\'errore " Seguiti" " Seguaci" diff --git a/amethyst/src/main/res/values-ja-rJP/strings.xml b/amethyst/src/main/res/values-ja-rJP/strings.xml index abe133ce6e..e7b5fa9eab 100644 --- a/amethyst/src/main/res/values-ja-rJP/strings.xml +++ b/amethyst/src/main/res/values-ja-rJP/strings.xml @@ -84,7 +84,6 @@ 追加 "リプライ先: " " と " - プロフィールバナー エラーメッセージの解析に失敗しました " フォロー" " フォロワー" diff --git a/amethyst/src/main/res/values-ja/strings.xml b/amethyst/src/main/res/values-ja/strings.xml index 8f44185669..ecf4984e12 100644 --- a/amethyst/src/main/res/values-ja/strings.xml +++ b/amethyst/src/main/res/values-ja/strings.xml @@ -41,7 +41,6 @@ 追加 "リプライ先: " " と " - プロフィールバナー " フォロー" " フォロワー" プロフィール diff --git a/amethyst/src/main/res/values-ko-rKR/strings.xml b/amethyst/src/main/res/values-ko-rKR/strings.xml index 4f370f4010..6d3c15e64d 100644 --- a/amethyst/src/main/res/values-ko-rKR/strings.xml +++ b/amethyst/src/main/res/values-ko-rKR/strings.xml @@ -83,7 +83,6 @@ 추가 "답글 대상: " " 및 " - 프로필 배너 오류 메시지 파싱 실패 " 팔로잉" " 팔로워" diff --git a/amethyst/src/main/res/values-lv-rLV/strings.xml b/amethyst/src/main/res/values-lv-rLV/strings.xml index 58b29e4f7f..b3e2c38bee 100644 --- a/amethyst/src/main/res/values-lv-rLV/strings.xml +++ b/amethyst/src/main/res/values-lv-rLV/strings.xml @@ -90,7 +90,6 @@ Pievienot "atbild uz " " un " - Profila reklāmkarogs Kļūda, parsējot kļūdas ziņojumu " Seko" " Sekotāji" diff --git a/amethyst/src/main/res/values-nl-rBE/strings.xml b/amethyst/src/main/res/values-nl-rBE/strings.xml index a1cc344623..d45b8b0baf 100644 --- a/amethyst/src/main/res/values-nl-rBE/strings.xml +++ b/amethyst/src/main/res/values-nl-rBE/strings.xml @@ -157,7 +157,6 @@ " en " -Profielbanner Fout bij verwerken foutmelding diff --git a/amethyst/src/main/res/values-nl-rNL/strings.xml b/amethyst/src/main/res/values-nl-rNL/strings.xml index 6f590ba570..f7bf44a553 100644 --- a/amethyst/src/main/res/values-nl-rNL/strings.xml +++ b/amethyst/src/main/res/values-nl-rNL/strings.xml @@ -97,7 +97,6 @@ Toevoegen "antwoordt op" " en " - Profielbanner Fout bij verwerken foutmelding "Volgend" "Volgers" diff --git a/amethyst/src/main/res/values-nl/strings.xml b/amethyst/src/main/res/values-nl/strings.xml index f12d94e2e8..82f6778d86 100644 --- a/amethyst/src/main/res/values-nl/strings.xml +++ b/amethyst/src/main/res/values-nl/strings.xml @@ -59,7 +59,6 @@ Toevoegen "reageert op " " en " - Profielbanner Fout bij het parsen van foutberichten " Volgend" " Volgers" diff --git a/amethyst/src/main/res/values-pl-rPL/strings.xml b/amethyst/src/main/res/values-pl-rPL/strings.xml index d8da099527..b60e54382d 100644 --- a/amethyst/src/main/res/values-pl-rPL/strings.xml +++ b/amethyst/src/main/res/values-pl-rPL/strings.xml @@ -105,7 +105,6 @@ Dodaj "odpowiadając do " " i " - Baner profilu Błąd podczas analizowania komunikatu o błędzie " Obserwowane" " Obserwujące" diff --git a/amethyst/src/main/res/values-pt-rBR/strings.xml b/amethyst/src/main/res/values-pt-rBR/strings.xml index 20d385d5c5..182118fe31 100644 --- a/amethyst/src/main/res/values-pt-rBR/strings.xml +++ b/amethyst/src/main/res/values-pt-rBR/strings.xml @@ -97,7 +97,6 @@ Adicionar "respondendo para " " e " - Banner do perfil Erro ao analisar mensagem de erro " Seguindo" " Seguidores" diff --git a/amethyst/src/main/res/values-pt-rPT/strings.xml b/amethyst/src/main/res/values-pt-rPT/strings.xml index 7b69cb5ebd..9b959048c4 100644 --- a/amethyst/src/main/res/values-pt-rPT/strings.xml +++ b/amethyst/src/main/res/values-pt-rPT/strings.xml @@ -83,7 +83,6 @@ Adicionar "respondendo para " " e " - Banner do perfil Erro ao analisar mensagem de erro " Seguindo" " Seguidores" diff --git a/amethyst/src/main/res/values-ru-rRU/strings.xml b/amethyst/src/main/res/values-ru-rRU/strings.xml index 570dddb345..2f67feb1c5 100644 --- a/amethyst/src/main/res/values-ru-rRU/strings.xml +++ b/amethyst/src/main/res/values-ru-rRU/strings.xml @@ -93,7 +93,6 @@ Добавить "ответ на " " и " - Баннер профиля Ошибка при анализе сообщения об ошибке " Подписок" " Подписчиков" diff --git a/amethyst/src/main/res/values-ru-rUA/strings.xml b/amethyst/src/main/res/values-ru-rUA/strings.xml index f08b5562c8..be1a159183 100644 --- a/amethyst/src/main/res/values-ru-rUA/strings.xml +++ b/amethyst/src/main/res/values-ru-rUA/strings.xml @@ -91,7 +91,6 @@ Добавить "ответ на " " и " - Баннер профиля Ошибка разбора сообщения об ошибке " Подписки" " Подписчики" diff --git a/amethyst/src/main/res/values-ru/strings.xml b/amethyst/src/main/res/values-ru/strings.xml index 2a7db29633..e6351b237d 100644 --- a/amethyst/src/main/res/values-ru/strings.xml +++ b/amethyst/src/main/res/values-ru/strings.xml @@ -42,7 +42,6 @@ Добавить "ответ на " " и " - Баннер профиля Ошибка при анализе сообщения об ошибке " Подписок" " Подписчиков" diff --git a/amethyst/src/main/res/values-sl-rSI/strings.xml b/amethyst/src/main/res/values-sl-rSI/strings.xml index babde04e80..5d0e1e8122 100644 --- a/amethyst/src/main/res/values-sl-rSI/strings.xml +++ b/amethyst/src/main/res/values-sl-rSI/strings.xml @@ -115,7 +115,6 @@ Za podpisovanje se je potrebno prijaviti s privatnim ključem Dodaj "odgovoriti " " in " - Pasica profila Napaka pri razčlembi sporočila o napaki " Sledi" " Sledilcev" diff --git a/amethyst/src/main/res/values-sr-rSP/strings.xml b/amethyst/src/main/res/values-sr-rSP/strings.xml index 0e8334209d..16a4fbabcc 100644 --- a/amethyst/src/main/res/values-sr-rSP/strings.xml +++ b/amethyst/src/main/res/values-sr-rSP/strings.xml @@ -85,7 +85,6 @@ Dodaj "odgovara na " " i " - Baner profila Greška pri parsiranju poruke o grešci " Praćeni" " Pratioci" diff --git a/amethyst/src/main/res/values-sv-rSE/strings.xml b/amethyst/src/main/res/values-sv-rSE/strings.xml index 60965073ba..64d559b90e 100644 --- a/amethyst/src/main/res/values-sv-rSE/strings.xml +++ b/amethyst/src/main/res/values-sv-rSE/strings.xml @@ -97,7 +97,6 @@ Lägg till "Svarar till " " och " - Profil Banner Fel vid tolkning av felmeddelande " Följer" " Följare" diff --git a/amethyst/src/main/res/values-sw/strings.xml b/amethyst/src/main/res/values-sw/strings.xml index ac17e1c835..a40a71dec1 100644 --- a/amethyst/src/main/res/values-sw/strings.xml +++ b/amethyst/src/main/res/values-sw/strings.xml @@ -86,7 +86,6 @@ Ongeza "kujibu " " na " - Bango la Wasifu Hitilafu katika kuchanganua ujumbe wa hitilafu " Kufuatia" " Wafuasi" diff --git a/amethyst/src/main/res/values-ta-rIN/strings.xml b/amethyst/src/main/res/values-ta-rIN/strings.xml index d121a4b3ec..d6a3a58699 100644 --- a/amethyst/src/main/res/values-ta-rIN/strings.xml +++ b/amethyst/src/main/res/values-ta-rIN/strings.xml @@ -86,7 +86,6 @@ சேர் "பதில் பெறுநர் " "மற்றும்" - தன்விவர பேனர் பிழை செய்தியை பாகுபடுத்துவதில் பிழை " பின்பற்றப்படுவோர்" " பின்பற்றுவோர்" diff --git a/amethyst/src/main/res/values-ta/strings.xml b/amethyst/src/main/res/values-ta/strings.xml index 4e88d783dc..539fbbb94e 100644 --- a/amethyst/src/main/res/values-ta/strings.xml +++ b/amethyst/src/main/res/values-ta/strings.xml @@ -37,7 +37,6 @@ சேர் "பதில் பெறுநர் " "மற்றும்" - தன்விவர பேனர் " பின்பற்றப்படுவோர்" " பின்பற்றுவோர்" தன்விவரம் diff --git a/amethyst/src/main/res/values-th-rTH/strings.xml b/amethyst/src/main/res/values-th-rTH/strings.xml index bf842b412a..8d41a00c42 100644 --- a/amethyst/src/main/res/values-th-rTH/strings.xml +++ b/amethyst/src/main/res/values-th-rTH/strings.xml @@ -85,7 +85,6 @@ เพิ่ม "ตอบกลับถึง " " และ " - หน้าปกโปรไฟล์ เกิดข้อผิดพลาดในการวิเคราะห์ข้อความแสดงข้อผิดพลาด " กำลังติดตาม" " ผู้ติดตาม" diff --git a/amethyst/src/main/res/values-th/strings.xml b/amethyst/src/main/res/values-th/strings.xml index 18c65b7f36..b8742c609b 100644 --- a/amethyst/src/main/res/values-th/strings.xml +++ b/amethyst/src/main/res/values-th/strings.xml @@ -58,7 +58,6 @@ เพิ่ม "ตอบกลับถึง " " และ " - หน้าปกโปรไฟล์ เกิดข้อผิดพลาดในการวิเคราะห์ข้อความแสดงข้อผิดพลาด " กำลังติดตาม" " ผู้ติดตาม" diff --git a/amethyst/src/main/res/values-tr-rTR/strings.xml b/amethyst/src/main/res/values-tr-rTR/strings.xml index 70f9a59779..f20231b19a 100644 --- a/amethyst/src/main/res/values-tr-rTR/strings.xml +++ b/amethyst/src/main/res/values-tr-rTR/strings.xml @@ -86,7 +86,6 @@ Ekle "yanıtlanıyor" "ve" - Profil Bayrağı Hata mesajı ayrıştırılırken hata oluştu "Takip edilenler" "Takipçiler" diff --git a/amethyst/src/main/res/values-tr/strings.xml b/amethyst/src/main/res/values-tr/strings.xml index 5771f4b57d..5006d96d76 100644 --- a/amethyst/src/main/res/values-tr/strings.xml +++ b/amethyst/src/main/res/values-tr/strings.xml @@ -37,7 +37,6 @@ Ekle "yanıtlanıyor" "ve" - Profil Bayrağı "Takip edilenler" "Takipçiler" Profil diff --git a/amethyst/src/main/res/values-uk-rUA/strings.xml b/amethyst/src/main/res/values-uk-rUA/strings.xml index 57bdfc2252..b3d47dc659 100644 --- a/amethyst/src/main/res/values-uk-rUA/strings.xml +++ b/amethyst/src/main/res/values-uk-rUA/strings.xml @@ -92,7 +92,6 @@ Додати "у відповідь " " та " - Банер профілю Помилка при обробці повідомлення про помилку " Підписок" " Підписників" diff --git a/amethyst/src/main/res/values-uk/strings.xml b/amethyst/src/main/res/values-uk/strings.xml index bc518633e8..88a2b83260 100644 --- a/amethyst/src/main/res/values-uk/strings.xml +++ b/amethyst/src/main/res/values-uk/strings.xml @@ -42,7 +42,6 @@ Додати "у відповідь " " та " - Банер профілю Помилка при обробці повідомлення про помилку " Підписок" " Підписників" diff --git a/amethyst/src/main/res/values-uz-rUZ/strings.xml b/amethyst/src/main/res/values-uz-rUZ/strings.xml index 8bee41e19f..de5f1e514c 100644 --- a/amethyst/src/main/res/values-uz-rUZ/strings.xml +++ b/amethyst/src/main/res/values-uz-rUZ/strings.xml @@ -88,7 +88,6 @@ Qo\'shish "Kimga javob yozilmoqda: " " va " - Profil banneri Xato xabarini tahlil qilishda xato " Kuzatilmoqda" " Kuzatuvchilar" diff --git a/amethyst/src/main/res/values-vi-rVN/strings.xml b/amethyst/src/main/res/values-vi-rVN/strings.xml index 9b6993200c..e07a33be65 100644 --- a/amethyst/src/main/res/values-vi-rVN/strings.xml +++ b/amethyst/src/main/res/values-vi-rVN/strings.xml @@ -80,7 +80,6 @@ Thêm "đang trả lời " " và " - Ảnh bìa hồ sơ Lỗi phân tích thông báo lỗi " Đang theo dõi" " Người theo dõi" diff --git a/amethyst/src/main/res/values-zh-rCN/strings.xml b/amethyst/src/main/res/values-zh-rCN/strings.xml index c886387571..3d638943a7 100644 --- a/amethyst/src/main/res/values-zh-rCN/strings.xml +++ b/amethyst/src/main/res/values-zh-rCN/strings.xml @@ -86,7 +86,6 @@ 添加 "回复 " " 和 " - 个人档案横幅 解析错误信息时出错 " 关注" " 粉丝" diff --git a/amethyst/src/main/res/values-zh-rHK/strings.xml b/amethyst/src/main/res/values-zh-rHK/strings.xml index 20ae19cd15..58669bf1cd 100644 --- a/amethyst/src/main/res/values-zh-rHK/strings.xml +++ b/amethyst/src/main/res/values-zh-rHK/strings.xml @@ -84,7 +84,6 @@ 添加 "回覆 " " 和 " - 個人檔案橫幅 解析错误信息时出错 " 關注" " 粉絲" diff --git a/amethyst/src/main/res/values-zh-rSG/strings.xml b/amethyst/src/main/res/values-zh-rSG/strings.xml index d7e4ab170a..dc3e5ba8bb 100644 --- a/amethyst/src/main/res/values-zh-rSG/strings.xml +++ b/amethyst/src/main/res/values-zh-rSG/strings.xml @@ -84,7 +84,6 @@ 添加 "回复 " " 和 " - 个人档案横幅 解析错误信息时出错 " 关注" " 粉丝" diff --git a/amethyst/src/main/res/values-zh-rTW/strings.xml b/amethyst/src/main/res/values-zh-rTW/strings.xml index 05c4f19837..650e06c0ca 100644 --- a/amethyst/src/main/res/values-zh-rTW/strings.xml +++ b/amethyst/src/main/res/values-zh-rTW/strings.xml @@ -85,7 +85,6 @@ 添加 "回覆 " " 和 " - 個人檔案橫幅 錯誤解析錯誤消息 " 關注" " 粉絲" diff --git a/amethyst/src/main/res/values-zh/strings.xml b/amethyst/src/main/res/values-zh/strings.xml index d2cd481637..5b5d79e395 100644 --- a/amethyst/src/main/res/values-zh/strings.xml +++ b/amethyst/src/main/res/values-zh/strings.xml @@ -39,7 +39,6 @@ 添加 "回复 " " 和 " - 个人档案横幅 " 关注" " 粉丝" 个人档案 diff --git a/amethyst/src/main/res/values/strings.xml b/amethyst/src/main/res/values/strings.xml index 5afa83b120..0561dfb3bc 100644 --- a/amethyst/src/main/res/values/strings.xml +++ b/amethyst/src/main/res/values/strings.xml @@ -103,7 +103,6 @@ Add "replying to " " and " - Profile Banner Error parsing error message " Following" " Followers" diff --git a/commons/plans/2026-08-30-commons-migration-sweep.md b/commons/plans/2026-08-30-commons-migration-sweep.md index f1d0d1dad8..11c7b662a8 100644 --- a/commons/plans/2026-08-30-commons-migration-sweep.md +++ b/commons/plans/2026-08-30-commons-migration-sweep.md @@ -569,8 +569,29 @@ Original findings, for reference: design decision**: `CachePruner`/`CacheSearch` call `Account.isFollowing(...)`; either `IAccount` grows it (DesktopIAccount must implement) or they take a narrower interface (recommended). -- **Wave 3: strings bridge** — a `stringRes` twin backed by Compose - resources in commons; gates ~210 otherwise-pure UI files. +- **Wave 3: strings bridge** — **BUILT (2026-09-01)**. The pieces: + - `commons/ui/StringRes.kt` (commonMain): `stringRes(StringResource)`, + formatted + plural variants, `loadStringRes`/`loadPluralStringRes` for + non-composable scopes. Thin delegates over compose-resources — no extra + cache (the library caches parsed locale files process-wide). + - App-side `ui/StringResourceCache.kt` gained `stringRes(StringResource)` + overloads delegating to the bridge, so ONE `stringRes` import serves + mixed files: migrating a key is just `R.string.x` → `Res.string.x` + (+ the two `commons.resources` imports). No aliasing, no churn. + - `tools/strings-migrate/migrate.py `: moves keys from app res to + commons composeResources across all 57 locales byte-for-byte (Crowdin + covers both trees with the same mapping — see crowdin.yml). It refuses + keys with bare `%s`/`%d` (compose-resources needs positional `%1$s`). + - Exemplar shipped: `profile_banner` (the ui/layouts cluster's only + string blocker) migrated + all 7 call-site files repointed. + - **Remaining Wave-3 work:** migrate keys feature-by-feature with this + tool (keys whose non-composable `ctx`-based call sites exist must have + those call sites adapted to `loadStringRes` first), then move the + now-unblocked composables. Note the layouts cluster ALSO needs theme + constants (`DividerThickness`, `Size55Modifier`, …) hoisted from app + `ui/theme/Shape.kt` into `commons/ui/theme/Sizes.kt`, plus + `painterRes`/`TimeAgo`/`NewItemsBubble` decisions — the audit's + "strings-only" tally under-counted transitive deps. - **Wave 4: Account/AccountViewModel decomposition** — long-tail. ### Environment notes for the next session (hard-won) diff --git a/commons/src/commonMain/composeResources/values-ar-rSA/strings.xml b/commons/src/commonMain/composeResources/values-ar-rSA/strings.xml index 7e198545e2..73855337c0 100644 --- a/commons/src/commonMain/composeResources/values-ar-rSA/strings.xml +++ b/commons/src/commonMain/composeResources/values-ar-rSA/strings.xml @@ -72,4 +72,5 @@ %1$d حدثًا %1$d حدث + لافتة الملف الشخصي diff --git a/commons/src/commonMain/composeResources/values-bn-rBD/strings.xml b/commons/src/commonMain/composeResources/values-bn-rBD/strings.xml index ee10f148f2..8ea92db5d0 100644 --- a/commons/src/commonMain/composeResources/values-bn-rBD/strings.xml +++ b/commons/src/commonMain/composeResources/values-bn-rBD/strings.xml @@ -59,4 +59,5 @@ %1$d টি ইভেন্ট %1$d টি ইভেন্ট + প্রোফাইলের ব্যানার diff --git a/commons/src/commonMain/composeResources/values-cs/strings.xml b/commons/src/commonMain/composeResources/values-cs/strings.xml index 33ae469b46..30ec092314 100644 --- a/commons/src/commonMain/composeResources/values-cs/strings.xml +++ b/commons/src/commonMain/composeResources/values-cs/strings.xml @@ -195,4 +195,5 @@ %1$d událostí %1$d událostí + Banner profilu diff --git a/commons/src/commonMain/composeResources/values-de-rDE/strings.xml b/commons/src/commonMain/composeResources/values-de-rDE/strings.xml index e57916e26d..800d5ebb67 100644 --- a/commons/src/commonMain/composeResources/values-de-rDE/strings.xml +++ b/commons/src/commonMain/composeResources/values-de-rDE/strings.xml @@ -185,4 +185,5 @@ %1$d Termin %1$d Termine + Profilbanner diff --git a/commons/src/commonMain/composeResources/values-de/strings.xml b/commons/src/commonMain/composeResources/values-de/strings.xml index d5a6756f10..d192c4bede 100644 --- a/commons/src/commonMain/composeResources/values-de/strings.xml +++ b/commons/src/commonMain/composeResources/values-de/strings.xml @@ -47,4 +47,5 @@ %1$d Termin %1$d Termine + Profilbanner diff --git a/commons/src/commonMain/composeResources/values-el-rGR/strings.xml b/commons/src/commonMain/composeResources/values-el-rGR/strings.xml index b515a8ece0..296a82d9fb 100644 --- a/commons/src/commonMain/composeResources/values-el-rGR/strings.xml +++ b/commons/src/commonMain/composeResources/values-el-rGR/strings.xml @@ -59,4 +59,5 @@ %1$d συμβάν %1$d συμβάντα + Ταπετσαρία Προφίλ diff --git a/commons/src/commonMain/composeResources/values-eo-rUY/strings.xml b/commons/src/commonMain/composeResources/values-eo-rUY/strings.xml index e997a707cd..4097117bd1 100644 --- a/commons/src/commonMain/composeResources/values-eo-rUY/strings.xml +++ b/commons/src/commonMain/composeResources/values-eo-rUY/strings.xml @@ -59,4 +59,5 @@ %1$d evento %1$d eventoj + Profila Murpapero diff --git a/commons/src/commonMain/composeResources/values-eo/strings.xml b/commons/src/commonMain/composeResources/values-eo/strings.xml index c32435de8e..80adca58e5 100644 --- a/commons/src/commonMain/composeResources/values-eo/strings.xml +++ b/commons/src/commonMain/composeResources/values-eo/strings.xml @@ -47,4 +47,5 @@ %1$d evento %1$d eventoj + Profila Murpapero diff --git a/commons/src/commonMain/composeResources/values-es-rES/strings.xml b/commons/src/commonMain/composeResources/values-es-rES/strings.xml index 1c5cb1e768..2f29658135 100644 --- a/commons/src/commonMain/composeResources/values-es-rES/strings.xml +++ b/commons/src/commonMain/composeResources/values-es-rES/strings.xml @@ -59,4 +59,5 @@ %1$d evento %1$d eventos + Banner de perfil diff --git a/commons/src/commonMain/composeResources/values-es-rMX/strings.xml b/commons/src/commonMain/composeResources/values-es-rMX/strings.xml index 553f60d945..a0236784a8 100644 --- a/commons/src/commonMain/composeResources/values-es-rMX/strings.xml +++ b/commons/src/commonMain/composeResources/values-es-rMX/strings.xml @@ -59,4 +59,5 @@ %1$d evento %1$d eventos + Banner del perfil diff --git a/commons/src/commonMain/composeResources/values-es-rUS/strings.xml b/commons/src/commonMain/composeResources/values-es-rUS/strings.xml index 553f60d945..a0236784a8 100644 --- a/commons/src/commonMain/composeResources/values-es-rUS/strings.xml +++ b/commons/src/commonMain/composeResources/values-es-rUS/strings.xml @@ -59,4 +59,5 @@ %1$d evento %1$d eventos + Banner del perfil diff --git a/commons/src/commonMain/composeResources/values-es/strings.xml b/commons/src/commonMain/composeResources/values-es/strings.xml index f249289707..ca9686ad0b 100644 --- a/commons/src/commonMain/composeResources/values-es/strings.xml +++ b/commons/src/commonMain/composeResources/values-es/strings.xml @@ -47,4 +47,5 @@ %1$d evento %1$d eventos + Banner de perfil diff --git a/commons/src/commonMain/composeResources/values-fa-rIR/strings.xml b/commons/src/commonMain/composeResources/values-fa-rIR/strings.xml index 30171c7cd3..ca7425df78 100644 --- a/commons/src/commonMain/composeResources/values-fa-rIR/strings.xml +++ b/commons/src/commonMain/composeResources/values-fa-rIR/strings.xml @@ -59,4 +59,5 @@ %1$d رویداد %1$d رویداد + بنر پروفایل diff --git a/commons/src/commonMain/composeResources/values-fa/strings.xml b/commons/src/commonMain/composeResources/values-fa/strings.xml index 9f5da29a94..8892492e98 100644 --- a/commons/src/commonMain/composeResources/values-fa/strings.xml +++ b/commons/src/commonMain/composeResources/values-fa/strings.xml @@ -47,4 +47,5 @@ %1$d رویداد %1$d رویداد + بنر پروفایل diff --git a/commons/src/commonMain/composeResources/values-fi-rFI/strings.xml b/commons/src/commonMain/composeResources/values-fi-rFI/strings.xml index befae60614..fb309725ed 100644 --- a/commons/src/commonMain/composeResources/values-fi-rFI/strings.xml +++ b/commons/src/commonMain/composeResources/values-fi-rFI/strings.xml @@ -59,4 +59,5 @@ %1$d tapahtuma %1$d tapahtumaa + Profiilin banneri diff --git a/commons/src/commonMain/composeResources/values-fr-rCA/strings.xml b/commons/src/commonMain/composeResources/values-fr-rCA/strings.xml index 149fe03b53..78fe56a4ea 100644 --- a/commons/src/commonMain/composeResources/values-fr-rCA/strings.xml +++ b/commons/src/commonMain/composeResources/values-fr-rCA/strings.xml @@ -56,4 +56,5 @@ %1$d événement %1$d événements + Bannière du profil diff --git a/commons/src/commonMain/composeResources/values-fr-rFR/strings.xml b/commons/src/commonMain/composeResources/values-fr-rFR/strings.xml index 7c0b8152a6..0b0dc32b94 100644 --- a/commons/src/commonMain/composeResources/values-fr-rFR/strings.xml +++ b/commons/src/commonMain/composeResources/values-fr-rFR/strings.xml @@ -58,4 +58,5 @@ %1$d événement %1$d événements + Bannière du profil diff --git a/commons/src/commonMain/composeResources/values-fr/strings.xml b/commons/src/commonMain/composeResources/values-fr/strings.xml index 5f8d82bc56..95ca2141c1 100644 --- a/commons/src/commonMain/composeResources/values-fr/strings.xml +++ b/commons/src/commonMain/composeResources/values-fr/strings.xml @@ -47,4 +47,5 @@ %1$d événement %1$d événements + Bannière du profil diff --git a/commons/src/commonMain/composeResources/values-hi-rIN/strings.xml b/commons/src/commonMain/composeResources/values-hi-rIN/strings.xml index 427fe50462..dd637ace0d 100644 --- a/commons/src/commonMain/composeResources/values-hi-rIN/strings.xml +++ b/commons/src/commonMain/composeResources/values-hi-rIN/strings.xml @@ -185,4 +185,5 @@ %1$d घटना %1$d घटनाएँ + परिचय ध्वजचित्र diff --git a/commons/src/commonMain/composeResources/values-hu-rHU/strings.xml b/commons/src/commonMain/composeResources/values-hu-rHU/strings.xml index 3faeb6acc3..03e8115b02 100644 --- a/commons/src/commonMain/composeResources/values-hu-rHU/strings.xml +++ b/commons/src/commonMain/composeResources/values-hu-rHU/strings.xml @@ -185,4 +185,5 @@ %1$d esemény %1$d esemény + Profilplakát diff --git a/commons/src/commonMain/composeResources/values-in-rID/strings.xml b/commons/src/commonMain/composeResources/values-in-rID/strings.xml index 8acf586aa3..59fdc5773a 100644 --- a/commons/src/commonMain/composeResources/values-in-rID/strings.xml +++ b/commons/src/commonMain/composeResources/values-in-rID/strings.xml @@ -55,4 +55,5 @@ %1$d acara + Banner Profil diff --git a/commons/src/commonMain/composeResources/values-in/strings.xml b/commons/src/commonMain/composeResources/values-in/strings.xml index c54b7242ce..877578c3a4 100644 --- a/commons/src/commonMain/composeResources/values-in/strings.xml +++ b/commons/src/commonMain/composeResources/values-in/strings.xml @@ -44,4 +44,5 @@ %1$d acara + Spanduk Profil diff --git a/commons/src/commonMain/composeResources/values-it-rIT/strings.xml b/commons/src/commonMain/composeResources/values-it-rIT/strings.xml index 86ba2bfb30..75f2c5168d 100644 --- a/commons/src/commonMain/composeResources/values-it-rIT/strings.xml +++ b/commons/src/commonMain/composeResources/values-it-rIT/strings.xml @@ -59,4 +59,5 @@ %1$d evento %1$d eventi + Immagine di copertina diff --git a/commons/src/commonMain/composeResources/values-ja-rJP/strings.xml b/commons/src/commonMain/composeResources/values-ja-rJP/strings.xml index 43c739a326..9768e7c804 100644 --- a/commons/src/commonMain/composeResources/values-ja-rJP/strings.xml +++ b/commons/src/commonMain/composeResources/values-ja-rJP/strings.xml @@ -56,4 +56,5 @@ %1$dイベント + プロフィールバナー diff --git a/commons/src/commonMain/composeResources/values-ja/strings.xml b/commons/src/commonMain/composeResources/values-ja/strings.xml index 8dd6571560..035e944ec4 100644 --- a/commons/src/commonMain/composeResources/values-ja/strings.xml +++ b/commons/src/commonMain/composeResources/values-ja/strings.xml @@ -44,4 +44,5 @@ %1$dイベント + プロフィールバナー diff --git a/commons/src/commonMain/composeResources/values-ko-rKR/strings.xml b/commons/src/commonMain/composeResources/values-ko-rKR/strings.xml index a6ea3e4c98..398bfb55a9 100644 --- a/commons/src/commonMain/composeResources/values-ko-rKR/strings.xml +++ b/commons/src/commonMain/composeResources/values-ko-rKR/strings.xml @@ -56,4 +56,5 @@ %1$d개 이벤트 + 프로필 배너 diff --git a/commons/src/commonMain/composeResources/values-lv-rLV/strings.xml b/commons/src/commonMain/composeResources/values-lv-rLV/strings.xml index d8e1158c51..50bd3099dd 100644 --- a/commons/src/commonMain/composeResources/values-lv-rLV/strings.xml +++ b/commons/src/commonMain/composeResources/values-lv-rLV/strings.xml @@ -62,4 +62,5 @@ %1$d notikums %1$d notikumi + Profila reklāmkarogs diff --git a/commons/src/commonMain/composeResources/values-nl-rBE/strings.xml b/commons/src/commonMain/composeResources/values-nl-rBE/strings.xml index fa55a5263f..63166b77c5 100644 --- a/commons/src/commonMain/composeResources/values-nl-rBE/strings.xml +++ b/commons/src/commonMain/composeResources/values-nl-rBE/strings.xml @@ -47,4 +47,5 @@ %1$d evenement %1$d evenementen + Profielbanner diff --git a/commons/src/commonMain/composeResources/values-nl-rNL/strings.xml b/commons/src/commonMain/composeResources/values-nl-rNL/strings.xml index dc39c5312d..771487f171 100644 --- a/commons/src/commonMain/composeResources/values-nl-rNL/strings.xml +++ b/commons/src/commonMain/composeResources/values-nl-rNL/strings.xml @@ -185,4 +185,5 @@ %1$d evenement %1$d evenementen + Profielbanner diff --git a/commons/src/commonMain/composeResources/values-nl/strings.xml b/commons/src/commonMain/composeResources/values-nl/strings.xml index fa55a5263f..63166b77c5 100644 --- a/commons/src/commonMain/composeResources/values-nl/strings.xml +++ b/commons/src/commonMain/composeResources/values-nl/strings.xml @@ -47,4 +47,5 @@ %1$d evenement %1$d evenementen + Profielbanner diff --git a/commons/src/commonMain/composeResources/values-pl-rPL/strings.xml b/commons/src/commonMain/composeResources/values-pl-rPL/strings.xml index 0faea98dde..5bc1b1923b 100644 --- a/commons/src/commonMain/composeResources/values-pl-rPL/strings.xml +++ b/commons/src/commonMain/composeResources/values-pl-rPL/strings.xml @@ -195,4 +195,5 @@ %1$d wydarzeń %1$d wydarzeń + Baner profilu diff --git a/commons/src/commonMain/composeResources/values-pt-rBR/strings.xml b/commons/src/commonMain/composeResources/values-pt-rBR/strings.xml index 2a084de094..e4f6eb40a9 100644 --- a/commons/src/commonMain/composeResources/values-pt-rBR/strings.xml +++ b/commons/src/commonMain/composeResources/values-pt-rBR/strings.xml @@ -185,4 +185,5 @@ %1$d evento %1$d eventos + Banner do perfil diff --git a/commons/src/commonMain/composeResources/values-pt-rPT/strings.xml b/commons/src/commonMain/composeResources/values-pt-rPT/strings.xml index 8dc2e20e1b..a0ec88e72b 100644 --- a/commons/src/commonMain/composeResources/values-pt-rPT/strings.xml +++ b/commons/src/commonMain/composeResources/values-pt-rPT/strings.xml @@ -59,4 +59,5 @@ %1$d evento %1$d eventos + Banner do perfil diff --git a/commons/src/commonMain/composeResources/values-ru-rRU/strings.xml b/commons/src/commonMain/composeResources/values-ru-rRU/strings.xml index 798507aae4..4742843cfb 100644 --- a/commons/src/commonMain/composeResources/values-ru-rRU/strings.xml +++ b/commons/src/commonMain/composeResources/values-ru-rRU/strings.xml @@ -66,4 +66,5 @@ %1$d событий %1$d события + Баннер профиля diff --git a/commons/src/commonMain/composeResources/values-ru-rUA/strings.xml b/commons/src/commonMain/composeResources/values-ru-rUA/strings.xml index 798507aae4..4742843cfb 100644 --- a/commons/src/commonMain/composeResources/values-ru-rUA/strings.xml +++ b/commons/src/commonMain/composeResources/values-ru-rUA/strings.xml @@ -66,4 +66,5 @@ %1$d событий %1$d события + Баннер профиля diff --git a/commons/src/commonMain/composeResources/values-ru/strings.xml b/commons/src/commonMain/composeResources/values-ru/strings.xml index 8d5d0c46e5..e78fd008f3 100644 --- a/commons/src/commonMain/composeResources/values-ru/strings.xml +++ b/commons/src/commonMain/composeResources/values-ru/strings.xml @@ -53,4 +53,5 @@ %1$d событий %1$d события + Баннер профиля diff --git a/commons/src/commonMain/composeResources/values-sl-rSI/strings.xml b/commons/src/commonMain/composeResources/values-sl-rSI/strings.xml index d28e471f8c..0266851a4b 100644 --- a/commons/src/commonMain/composeResources/values-sl-rSI/strings.xml +++ b/commons/src/commonMain/composeResources/values-sl-rSI/strings.xml @@ -195,4 +195,5 @@ %1$d dogodki %1$d dogodkov + Pasica profila diff --git a/commons/src/commonMain/composeResources/values-sr-rSP/strings.xml b/commons/src/commonMain/composeResources/values-sr-rSP/strings.xml index 1db730ee8b..3fb2d7fe56 100644 --- a/commons/src/commonMain/composeResources/values-sr-rSP/strings.xml +++ b/commons/src/commonMain/composeResources/values-sr-rSP/strings.xml @@ -62,4 +62,5 @@ %1$d događaja %1$d događaja + Baner profila diff --git a/commons/src/commonMain/composeResources/values-sv-rSE/strings.xml b/commons/src/commonMain/composeResources/values-sv-rSE/strings.xml index 2d8dd924fa..495ec2d5be 100644 --- a/commons/src/commonMain/composeResources/values-sv-rSE/strings.xml +++ b/commons/src/commonMain/composeResources/values-sv-rSE/strings.xml @@ -185,4 +185,5 @@ %1$d händelse %1$d händelser + Profil Banner diff --git a/commons/src/commonMain/composeResources/values-sw/strings.xml b/commons/src/commonMain/composeResources/values-sw/strings.xml index a76c729faf..cdaf10b86e 100644 --- a/commons/src/commonMain/composeResources/values-sw/strings.xml +++ b/commons/src/commonMain/composeResources/values-sw/strings.xml @@ -59,4 +59,5 @@ tukio %1$d matukio %1$d + Bango la Wasifu diff --git a/commons/src/commonMain/composeResources/values-ta-rIN/strings.xml b/commons/src/commonMain/composeResources/values-ta-rIN/strings.xml index e0efd7685b..4afbb9a7ef 100644 --- a/commons/src/commonMain/composeResources/values-ta-rIN/strings.xml +++ b/commons/src/commonMain/composeResources/values-ta-rIN/strings.xml @@ -59,4 +59,5 @@ %1$d நிகழ்வு %1$d நிகழ்வுகள் + தன்விவர பேனர் diff --git a/commons/src/commonMain/composeResources/values-ta/strings.xml b/commons/src/commonMain/composeResources/values-ta/strings.xml index ab3ce98870..8925596784 100644 --- a/commons/src/commonMain/composeResources/values-ta/strings.xml +++ b/commons/src/commonMain/composeResources/values-ta/strings.xml @@ -47,4 +47,5 @@ %1$d நிகழ்வு %1$d நிகழ்வுகள் + தன்விவர பேனர் diff --git a/commons/src/commonMain/composeResources/values-th-rTH/strings.xml b/commons/src/commonMain/composeResources/values-th-rTH/strings.xml index 708af29822..b43ac3ea16 100644 --- a/commons/src/commonMain/composeResources/values-th-rTH/strings.xml +++ b/commons/src/commonMain/composeResources/values-th-rTH/strings.xml @@ -56,4 +56,5 @@ %1$d กิจกรรม + หน้าปกโปรไฟล์ diff --git a/commons/src/commonMain/composeResources/values-th/strings.xml b/commons/src/commonMain/composeResources/values-th/strings.xml index caf3deb98d..b3479b3b3c 100644 --- a/commons/src/commonMain/composeResources/values-th/strings.xml +++ b/commons/src/commonMain/composeResources/values-th/strings.xml @@ -44,4 +44,5 @@ %1$d กิจกรรม + หน้าปกโปรไฟล์ diff --git a/commons/src/commonMain/composeResources/values-tr-rTR/strings.xml b/commons/src/commonMain/composeResources/values-tr-rTR/strings.xml index e2d1a28343..ce631d3186 100644 --- a/commons/src/commonMain/composeResources/values-tr-rTR/strings.xml +++ b/commons/src/commonMain/composeResources/values-tr-rTR/strings.xml @@ -59,4 +59,5 @@ %1$d etkinlik %1$d etkinlik + Profil Bayrağı diff --git a/commons/src/commonMain/composeResources/values-tr/strings.xml b/commons/src/commonMain/composeResources/values-tr/strings.xml index dc3ba9d5f9..23f90ada88 100644 --- a/commons/src/commonMain/composeResources/values-tr/strings.xml +++ b/commons/src/commonMain/composeResources/values-tr/strings.xml @@ -47,4 +47,5 @@ %1$d etkinlik %1$d etkinlik + Profil Bayrağı diff --git a/commons/src/commonMain/composeResources/values-uk-rUA/strings.xml b/commons/src/commonMain/composeResources/values-uk-rUA/strings.xml index e351d425f6..ac441e5572 100644 --- a/commons/src/commonMain/composeResources/values-uk-rUA/strings.xml +++ b/commons/src/commonMain/composeResources/values-uk-rUA/strings.xml @@ -66,4 +66,5 @@ %1$d подій %1$d подій + Банер профілю diff --git a/commons/src/commonMain/composeResources/values-uk/strings.xml b/commons/src/commonMain/composeResources/values-uk/strings.xml index 8c587d77b3..b3d7ea2a12 100644 --- a/commons/src/commonMain/composeResources/values-uk/strings.xml +++ b/commons/src/commonMain/composeResources/values-uk/strings.xml @@ -53,4 +53,5 @@ %1$d подій %1$d подій + Банер профілю diff --git a/commons/src/commonMain/composeResources/values-uz-rUZ/strings.xml b/commons/src/commonMain/composeResources/values-uz-rUZ/strings.xml index cb2694e069..1d785f6d18 100644 --- a/commons/src/commonMain/composeResources/values-uz-rUZ/strings.xml +++ b/commons/src/commonMain/composeResources/values-uz-rUZ/strings.xml @@ -59,4 +59,5 @@ %1$d tadbir %1$d tadbir + Profil banneri diff --git a/commons/src/commonMain/composeResources/values-vi-rVN/strings.xml b/commons/src/commonMain/composeResources/values-vi-rVN/strings.xml index f902ab326b..014f5379f5 100644 --- a/commons/src/commonMain/composeResources/values-vi-rVN/strings.xml +++ b/commons/src/commonMain/composeResources/values-vi-rVN/strings.xml @@ -56,4 +56,5 @@ %1$d sự kiện + Ảnh bìa hồ sơ diff --git a/commons/src/commonMain/composeResources/values-zh-rCN/strings.xml b/commons/src/commonMain/composeResources/values-zh-rCN/strings.xml index 6edb7c0037..39a10e4514 100644 --- a/commons/src/commonMain/composeResources/values-zh-rCN/strings.xml +++ b/commons/src/commonMain/composeResources/values-zh-rCN/strings.xml @@ -146,4 +146,5 @@ %1$d 个活动 + 个人档案横幅 diff --git a/commons/src/commonMain/composeResources/values-zh-rHK/strings.xml b/commons/src/commonMain/composeResources/values-zh-rHK/strings.xml index e742f3188c..6209e483cd 100644 --- a/commons/src/commonMain/composeResources/values-zh-rHK/strings.xml +++ b/commons/src/commonMain/composeResources/values-zh-rHK/strings.xml @@ -57,4 +57,5 @@ %1$d 个活动 + 個人檔案橫幅 diff --git a/commons/src/commonMain/composeResources/values-zh-rSG/strings.xml b/commons/src/commonMain/composeResources/values-zh-rSG/strings.xml index e742f3188c..50d837ab04 100644 --- a/commons/src/commonMain/composeResources/values-zh-rSG/strings.xml +++ b/commons/src/commonMain/composeResources/values-zh-rSG/strings.xml @@ -57,4 +57,5 @@ %1$d 个活动 + 个人档案横幅 diff --git a/commons/src/commonMain/composeResources/values-zh-rTW/strings.xml b/commons/src/commonMain/composeResources/values-zh-rTW/strings.xml index 07a5fb96e0..98971d90fb 100644 --- a/commons/src/commonMain/composeResources/values-zh-rTW/strings.xml +++ b/commons/src/commonMain/composeResources/values-zh-rTW/strings.xml @@ -57,4 +57,5 @@ %1$d 個活動 + 個人檔案橫幅 diff --git a/commons/src/commonMain/composeResources/values-zh/strings.xml b/commons/src/commonMain/composeResources/values-zh/strings.xml index 7e95227a64..b8db63acb7 100644 --- a/commons/src/commonMain/composeResources/values-zh/strings.xml +++ b/commons/src/commonMain/composeResources/values-zh/strings.xml @@ -44,4 +44,5 @@ %1$d 个活动 + 个人档案横幅 diff --git a/commons/src/commonMain/composeResources/values/strings.xml b/commons/src/commonMain/composeResources/values/strings.xml index 422bfb4e25..8dfbf65cbb 100644 --- a/commons/src/commonMain/composeResources/values/strings.xml +++ b/commons/src/commonMain/composeResources/values/strings.xml @@ -197,4 +197,5 @@ %1$d event %1$d events + Profile Banner diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/StringRes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/StringRes.kt new file mode 100644 index 0000000000..8bfca18e58 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/StringRes.kt @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.ui + +import androidx.compose.runtime.Composable +import org.jetbrains.compose.resources.PluralStringResource +import org.jetbrains.compose.resources.StringResource +import org.jetbrains.compose.resources.getPluralString +import org.jetbrains.compose.resources.getString +import org.jetbrains.compose.resources.pluralStringResource +import org.jetbrains.compose.resources.stringResource + +/** + * The Compose-resources twin of the Android app's `stringRes` family + * (`amethyst/.../ui/StringResourceCache.kt`). Same call shape, portable + * backing: a file migrating from the app changes only the import and swaps + * `R.string.key` for `Res.string.key` — every `stringRes(...)` call site + * stays as written. + * + * No extra cache on purpose: unlike Android's `Resources.getString` (the + * >1 ms lookups the app-side LruCache exists for), compose-resources parses + * each locale's string file once into a process-wide cache, so repeat + * lookups are map hits and the library handles locale changes itself. If + * profiling ever says otherwise, this is the one place to add it. + * + * Format args use the positional `%1$s` form. Compose-resources does NOT + * understand bare `%s`/`%d` — `tools/strings-migrate` flags those at + * migration time. + */ +@Composable +fun stringRes(id: StringResource): String = stringResource(id) + +@Composable +fun stringRes( + id: StringResource, + vararg args: Any, +): String = stringResource(id, *args) + +@Composable +fun pluralStringRes( + id: PluralStringResource, + count: Int, +): String = pluralStringResource(id, count) + +@Composable +fun pluralStringRes( + id: PluralStringResource, + count: Int, + vararg args: Any, +): String = pluralStringResource(id, count, *args) + +/** Non-composable resolver (launch/onClick scopes) — twin of the `ctx`-taking overloads. */ +suspend fun loadStringRes(id: StringResource): String = getString(id) + +suspend fun loadStringRes( + id: StringResource, + vararg args: Any, +): String = getString(id, *args) + +/** Non-composable plural resolver — twin of the app's `pluralStringRes(ctx, ...)`. */ +suspend fun loadPluralStringRes( + id: PluralStringResource, + count: Int, + vararg args: Any, +): String = if (args.isEmpty()) getPluralString(id, count) else getPluralString(id, count, *args) diff --git a/tools/strings-migrate/README.md b/tools/strings-migrate/README.md new file mode 100644 index 0000000000..16aa92657b --- /dev/null +++ b/tools/strings-migrate/README.md @@ -0,0 +1,20 @@ +# strings-migrate + +Moves string keys from the Android app's `res/` into commons Compose +resources (`commons/src/commonMain/composeResources`) across **all** +locales in one shot, preserving each element byte-for-byte so Crowdin +sees a pure move. Both trees are Crowdin-managed with the same android +layout (see `crowdin.yml`), so a migrated key keeps its translations. + +```bash +tools/strings-migrate/migrate.py copy_to_clipboard relay_info +``` + +After migrating, repoint the code: `R.string.key` becomes `Res.string.key` +(`com.vitorpamplona.amethyst.commons.resources`), and the composable keeps +calling `stringRes(...)` via the commons bridge +(`com.vitorpamplona.amethyst.commons.ui.stringRes`). + +The tool refuses keys whose value uses bare `%s`/`%d`: compose-resources +only formats positional `%1$s` args. Rewrite those keys (code and every +locale) first. diff --git a/tools/strings-migrate/migrate.py b/tools/strings-migrate/migrate.py new file mode 100755 index 0000000000..ec9448379f --- /dev/null +++ b/tools/strings-migrate/migrate.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 +"""Move string keys from the Android app's res/ to commons Compose resources. + +Usage: tools/strings-migrate/migrate.py key1 key2 ... + +For the default locale and every values-* locale dir, each named + or element is removed from + amethyst/src/main/res//strings.xml +and appended (before ) to + commons/src/commonMain/composeResources//strings.xml +creating the commons locale file when a translation exists that commons +doesn't carry yet. Elements are moved verbatim (raw XML slice), so +escaping, CDATA and comments inside values survive byte-for-byte and +Crowdin sees a pure move. + +Fails loudly when a key's default-locale value uses non-positional format +specifiers (bare %s / %d): compose-resources only formats the positional +%1$s form, so those keys must be rewritten (in code AND all locales) +before migrating. Run from the repo root. +""" +import os +import re +import sys + +APP_RES = "amethyst/src/main/res" +COMMONS_RES = "commons/src/commonMain/composeResources" + +NEW_FILE_TEMPLATE = '\n\n\n' + +# %s, %d, %.2f ... without a position (%1$s). %% is a literal percent. +BARE_FORMAT = re.compile(r"%(?!%)(?!\d+\$)[-#+ 0,(]*\d*(?:\.\d+)?[a-zA-Z]") + + +def element_pattern(key: str) -> re.Pattern: + return re.compile( + r"[ \t]*<(string|plurals)\s+name=\"" + re.escape(key) + r"\"[^>]*?(?:/>|>.*?)[ \t]*\n?", + re.S, + ) + + +def extract(path: str, key: str): + """Remove key's element from path; return the element text or None.""" + if not os.path.exists(path): + return None + src = open(path, encoding="utf-8").read() + m = element_pattern(key).search(src) + if not m: + return None + open(path, "w", encoding="utf-8").write(src[: m.start()] + src[m.end() :]) + return m.group(0).strip("\n") + + +def append(path: str, elements: list): + if os.path.exists(path): + src = open(path, encoding="utf-8").read() + else: + os.makedirs(os.path.dirname(path), exist_ok=True) + src = NEW_FILE_TEMPLATE + close = src.rindex("") + block = "".join(" " + el.strip() + "\n" for el in elements) + open(path, "w", encoding="utf-8").write(src[:close] + block + src[close:]) + + +def main(keys): + default_src = os.path.join(APP_RES, "values", "strings.xml") + default_text = open(default_src, encoding="utf-8").read() + + for key in keys: + m = element_pattern(key).search(default_text) + if not m: + sys.exit(f"ERROR: key '{key}' not found in {default_src}") + if BARE_FORMAT.search(m.group(0)): + sys.exit( + f"ERROR: key '{key}' uses a non-positional format specifier (bare %s/%d).\n" + "compose-resources only formats %1$s-style args - rewrite the key " + "(code + every locale) before migrating." + ) + + locale_dirs = ["values"] + sorted( + d for d in os.listdir(APP_RES) if d.startswith("values-") and os.path.exists(os.path.join(APP_RES, d, "strings.xml")) + ) + + moved_total = 0 + for d in locale_dirs: + src_path = os.path.join(APP_RES, d, "strings.xml") + elements = [] + for key in keys: + el = extract(src_path, key) + if el is not None: + elements.append(el) + if elements: + append(os.path.join(COMMONS_RES, d, "strings.xml"), elements) + moved_total += len(elements) + print(f"{d}: moved {len(elements)}") + print(f"done: {moved_total} elements across {len(locale_dirs)} locale dirs") + + +if __name__ == "__main__": + if len(sys.argv) < 2: + sys.exit(__doc__) + main(sys.argv[1:])