Index of every page on this site: llms.txt
All skills
cpinan avatar

/corta-spam-add-localized-string

@10c0750
Run it yourself

Use when adding a new user-facing string, plural, or count to the Corta Spam app. This project has THREE separate resource trees that each need every string, across FOUR locales, plus locale-specific plural rules that fail the build. Easy to update only one and ship an English fallback by accident.

  • 1 file
  • 6.1 KB
  • Updated 4 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/cpinan/corta-spam/corta-spam-add-localized-string

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈83 tokens for metadata: the name and description. ≈1.4k when used: this file.

Description uses 4.2% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈333 characters, or 4.2%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Add a localized string — Corta Spam

Corta Spam supports 4 locales: en (default), es, hi, pt, across three separate resource trees. A string added to only one of them silently falls back to English for that locale's users. Always check which the call site needs before adding anywhere.

TranslationCompletenessTest now enforces this (shared/src/androidUnitTest/.../TranslationCompletenessTest.kt). It walks all three trees in both directions — missing translations and keys that exist only in a translation — and fails the build. On the day it was written it found eleven real gaps, including the in-app privacy policy and terms, plus eight keys nothing referenced and one that existed only in Spanish. Do not delete or weaken it to make an addition pass.

Android Lint's own MissingTranslation check is deliberately disabled in androidApp/build.gradle.kts: it can only see one of the three trees, so a green lint run was actively misleading.

System 1 — Compose Multiplatform resources

Path: shared/src/commonMain/composeResources/values{,-es,-hi,-pt}/strings.xml

Use for: anything rendered from a @Composable (screens, dialogs) via stringResource(Res.string.foo). This is what almost all UI strings use.

Add the same <string name="..."> key to all 4 files:

  • values/strings.xml (English — required, this is the fallback)
  • values-es/strings.xml
  • values-hi/strings.xml
  • values-pt/strings.xml

For strings with placeholders (e.g. a count), use %1$d/%1$s and call stringResource(Res.string.foo, value) — keep formatting in the Composable, not pre-formatted in ViewModel/domain code (this project's convention: presentation-edge formatting only).

After adding, the generated Res.string.foo accessor needs a rebuild (ktlintCheck/compile will show unresolved-reference errors if the key is missing from even one locale file — SQLDelight-style codegen requires all locale files to at least have the default-locale keys present via fallback, but ktlint import-ordering will flag it if you import the resource before it exists).

System 3 — The shared module's Android resources

Path: shared/src/androidMain/res/values{,-es,-hi,-pt}/strings.xml

Use for: strings the shared module needs synchronously from a non-Composable, non-suspend context. There is exactly one today — auto_responder_default_script, read from SqlAutoResponderRepository's constructor via AutoResponderDefaults, which cannot use the Compose resource system because getString there is suspend.

Reach it with import org.carlospinan.bloqueador.app.shared.R (the shared module's R class, not the app's). Supply the iOS side a constant in PlatformModule.ios.kt.

System 2 — Native Android resources

Path: androidApp/src/main/res/values{,-es,-hi,-pt}/strings.xml

Use for: anything read from non-suspend, non-Composable call sites — BroadcastReceivers, Call.Callback, NotificationCompat builders, Service classes (e.g. IncomingCallNotifier.kt, CallActionReceiver.kt, PassthroughInCallService.kt). These need synchronous context.getString(), which Compose resources don't give you outside a coroutine/Composable.

Same rule: add the key to all 4 locale files under androidApp/src/main/res/.

Plurals

A count in a string is a <plurals>, not %1$d in a <string>. "Called 1 times" is wrong in every locale this app ships, and Android Lint fails the build on it (PluralsCandidate, then ImpliedQuantity).

Two traps that cost a build each:

  • In Hindi and Brazilian Portuguese the one category covers both 0 and 1, so the one form must still contain the number: %1$d बार कॉल किया, not एक बार कॉल किया. Lint's message is The quantity 'one' matches more than one specific number in this locale (0, 1).
  • Add the plural to both the Compose tree and the Android tree if both render it — read with pluralStringResource(Res.plurals.x, count, count) and resources.getQuantityString(R.plurals.x, count, count) respectively. Note the count is passed twice: once to select the form, once to fill the placeholder.

Never build sentences outside the UI

A string assembled in a ViewModel, repository or domain class cannot be localized — those layers have no access to string resources. This project got that wrong three times over and had to undo it: block reasons (which were also persisted in English, freezing the call log in whatever language it was written in), statistics day labels, and backup result messages.

The rule: the data layer emits data; the Composable chooses words. If you find yourself writing an English sentence anywhere under commonMain that is not a log message, stop.

Inside a LaunchedEffect or other coroutine, stringResource is unavailable — use the suspend org.jetbrains.compose.resources.getString(Res.string.x, args...) instead of resolving format strings outside the collector and substituting by hand.

Checklist

  1. Identify which system the call site needs (Composable → System 1; Android component/callback in androidApp → System 2; shared-module synchronous read → System 3). If unsure, check how a similar existing string near that call site is referenced.
  2. Add the key + English string first.
  3. Add es/hi/pt translations to the same key in the other 3 locale files of the same system — don't skip a locale even if the translation is rough; a missing locale entry falls back to English for that locale's users, which has been the actual bug this project fixes proactively (e.g. app_name was only in values/ for es/hi/pt until this was caught).
  4. Run ./scripts/verify.sh — TranslationCompletenessTest and Android Lint both gate this.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 10c0750. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 weeks ago.

Steadyupdated 4 months ago
metadata
{
  "type": "project-runbook",
  "version": "1.0.0"
}

README badge

README badge for cpinan/corta-spam/corta-spam-add-localized-string