一键导入
localization
Properly work with localization in Android projects. Use this skill when adding new string resources, working with plurals, formatting dates and texts.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Properly work with localization in Android projects. Use this skill when adding new string resources, working with plurals, formatting dates and texts.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Correct handling of safe areas in Jetpack Compose Android applications. Use when working with TopAppBar, Scaffold, and screen safe areas in Jetpack-WorkoutApp.
Guide using dimension resources for UI sizes, spacings, and paddings in Android Compose. Use when creating or modifying UI components, replacing hardcoded dp values, or ensuring consistency across Compose screens.
Block UI screen content during data loading or asynchronous operations with loading indicator display. Use this skill when developing screens with network requests, CRUD operations, and other asynchronous actions.
Implement pull-to-refresh in Jetpack Compose using Material 3 PullToRefreshBox. Use this skill when adding data refresh capability on screens with lists or cards.
Write tests correctly in Android projects. Use this skill when writing any type of tests (unit, integration, UI), testing business logic, network functions, and UI components.
| name | localization |
| description | Properly work with localization in Android projects. Use this skill when adding new string resources, working with plurals, formatting dates and texts. |
Basic rules:
res/values/strings.xml (Russian) and res/values-en/strings.xml (English)name in lowercase with underscoresExample of adding a string:
<!-- res/values/strings.xml -->
<string name="welcome_message">Добро пожаловать!</string>
<!-- res/values-en/strings.xml -->
<string name="welcome_message">Welcome!</string>
Usage in code:
context.getString(R.string.welcome_message)
// or in XML
android:text="@string/welcome_message"
When to use:
Russian language rule:
one - 1, 21, 31, 41...few - 2-4, 22-24, 32-34...many - 0, 5-20, 25-30, 35-40...other - for all other cases (usually not used in Russian)Example:
<!-- res/values/strings.xml -->
<plurals name="days_count">
<item quantity="one">%d день</item>
<item quantity="few">%d дня</item>
<item quantity="many">%d дней</item>
<item quantity="other">%d дней</item>
</plurals>
<!-- res/values-en/strings.xml -->
<plurals name="days_count">
<item quantity="one">%d day</item>
<item quantity="other">%d days</item>
</plurals>
Usage in code:
val days = 5
val text = resources.getQuantityString(R.plurals.days_count, days, days)
// Result: "5 дней" (ru) or "5 days" (en)
Basic tools:
String.format() - for formatting strings with placeholdersMessageFormat - for complex formatting (if needed)DateFormat - for dates considering user localeString formatting example:
<!-- res/values/strings.xml -->
<string name="items_count_format">Найдено %d элементов</string>
<!-- res/values-en/strings.xml -->
<string name="items_count_format">Found %d items</string>
Usage in code:
val count = 42
val text = getString(R.string.items_count_format, count)
// Result: "Найдено 42 элементов"
Date formatting example:
val date = LocalDate.now()
val formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)
val formattedDate = date.format(formatter)
// Result depends on device locale
Important rule: All logs in code are written in Russian regardless of app localization
// Correct
Log.e(TAG, "Ошибка загрузки данных: ${error.message}")
Log.i(TAG, "Загружено $count элементов")
// Incorrect
Log.e(TAG, "Error loading data: ${error.message}")
String grouping:
auth_, parks_, events_)Grouping example:
<!-- Authorization -->
<string name="auth_login">Войти</string>
<string name="auth_password">Пароль</string>
<string name="auth_forgot_password">Забыли пароль?</string>
<!-- Parks -->
<string name="parks_title">Площадки</string>
<string name="parks_empty">Нет площадок</string>
<string name="parks_filter">Фильтр</string>
Rules:
%1$s, %2$d) for strings with multiple substitutionsExample with multiple parameters:
<!-- res/values/strings.xml -->
<string name="user_profile">%1$s, %2$d лет</string>
<!-- res/values-en/strings.xml -->
<string name="user_profile">%1$s, %2$d years old</string>
Usage:
val name = "Иван"
val age = 25
val text = getString(R.string.user_profile, name, age)
// Result: "Иван, 25 лет"
Localized error messages:
<!-- Network errors -->
<string name="error_network">Ошибка сети. Проверьте подключение к интернету.</string>
<string name="error_timeout">Время ожидания истекло. Попробуйте еще раз.</string>
<!-- Authorization errors -->
<string name="error_invalid_credentials">Неверный логин или пароль</string>
<string name="error_unauthorized">Необходима авторизация</string>
<!-- Data errors -->
<string name="error_not_found">Данные не найдены</string>
<string name="error_invalid_data">Неверные данные</string>
Usage in code:
try {
loadData()
} catch (e: IOException) {
Log.e(TAG, "Ошибка сети: ${e.message}")
showError(getString(R.string.error_network))
}
res/values/strings.xml (Russian)res/values-en/strings.xml (English)name is unique and follows naming convention