Skip to content

Localization Prompt Template

Him188 edited this page Apr 16, 2025 · 3 revisions
Convert hard-coded strings in the following files to use resources:
- 

You should do file-by-file. For each file:

1. Update `app-lang/src/androidMain/res/values/strings.xml` and translations in `values-zh-rTW`, `values-zh-rCN` and `values-rHK`. Ignore other locales. Ensure you prefix the string keys. For example, if the package name is `me.him188.ani.app.ui.settings.mediasource`, you should prefix string keys with "settings_mediasource_".
2. Add import `me.him188.ani.app.ui.lang.*` and `org.jetbrains.compose.resources.*` for accessing resources. Note that you should star-import `.lang.*`, not just import `.lang.Lang`, because the strings are extension propreties on the Lang object.
3. Replace code in Compose using `stringResource(Lang.xxx)`. 
If the hardcoded string is not in compose (an error reported on `stringResource`), you may either use the suspend variant `getString(Lang.xxx)` if we have a coroutine scope available, or you load the resource into a variable in Composable code, then use it in the non-compose code.
You can just leave references to `Lang.xxx` red, as it will be generated later. 
Don't translate checks in kotlin `require()`, `check`, and `error` functions, like array bound check "selectedItemIndex must be -1 or in the range of items".

操作方法:

  1. 在 Junie 问以上问题
  2. IDE run hot reload, 挂在后台不管
  3. Editor 打开 me.him188.ani.app.ui.lang.CommonMainString0, 保持文件为打开状态
  4. 等待 Junie 操作完成
  5. 检查并 Commit
Clone this wiki locally