Description
Currently, some of the app's UI strings are hardcoded directly into Kotlin (.kt) files. To enhance the app's localization capabilities and make it easier to manage translations, we need to migrate all hardcoded strings into the strings.xml file. This will allow us to support multiple languages without changing the codebase and improve the maintainability of the application.
Tasks:
- Identify all hardcoded strings in the Kotlin files (
.kt).
- Move those strings to the
strings.xml resource file under the appropriate <string> tags.
- Replace the hardcoded strings in the Kotlin files with references to the corresponding string resources.
- Ensure that the application works correctly after the migration and all strings are properly localized.
Example
This is in Mess.kt line : 217 - 226
Before:
// Hardcoded string in Kotlin file
if (!yearSelected) {
toast("Please Select a year")
} else if (!genderSelected) {
toast("Please Select gender")
} else if (!batchSelected) {
toast("Please Select a batch")
} else {
onResult(target)
dialog.dismiss()
}
After:
- Add strings to
res/values/strings.xml:
<resources>
<string name="select_year">Please Select a year</string>
<string name="select_gender">Please Select gender</string>
<string name="select_batch">Please Select a batch</string>
</resources>
- Modify Kotlin code to reference the string resources:
// Using string resource from strings.xml
if (!yearSelected) {
toast(getString(R.string.select_year))
} else if (!genderSelected) {
toast(getString(R.string.select_gender)
} else if (!batchSelected) {
toast(getString(R.string.select_batch)
} else {
onResult(target)
dialog.dismiss()
}
Expected Outcome
- All hardcoded strings in
.kt files are moved to strings.xml.
- The app continues to work seamlessly with localized strings.
- The code is cleaner and easier to maintain.
Create single PR per file.
Description
Currently, some of the app's UI strings are hardcoded directly into Kotlin (
.kt) files. To enhance the app's localization capabilities and make it easier to manage translations, we need to migrate all hardcoded strings into thestrings.xmlfile. This will allow us to support multiple languages without changing the codebase and improve the maintainability of the application.Tasks:
.kt).strings.xmlresource file under the appropriate<string>tags.Example
This is in
Mess.ktline : 217 - 226Before:
After:
res/values/strings.xml:Expected Outcome
.ktfiles are moved tostrings.xml.Create single PR per file.