Skip to content

Move all strings from Kotlin files to strings.xml for Localization #1

@theayushyadav11

Description

@theayushyadav11

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:

  1. Identify all hardcoded strings in the Kotlin files (.kt).
  2. Move those strings to the strings.xml resource file under the appropriate <string> tags.
  3. Replace the hardcoded strings in the Kotlin files with references to the corresponding string resources.
  4. 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:

  1. 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>
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomersmulti-assigneesCan be assigned to multiple contributers at the same time.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions