Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong month cases for Russian\Ukranian languages #75

Open
akaish opened this issue Mar 16, 2023 · 0 comments
Open

Wrong month cases for Russian\Ukranian languages #75

akaish opened this issue Mar 16, 2023 · 0 comments

Comments

@akaish
Copy link

akaish commented Mar 16, 2023

Hello, I'm working on app that targeted to Russian\Ukrainian\Belarus audience and noticed that when phone language is Russian month names in picker are in wrong case. In some languages word spelling differs depends on context, it is called cases. I don't mean upper\lower case.

For example, "марта 2023" instead of "март 2023" (March 2023). When you want month name of a year, you spell it in nominative case (март 2023), however when subject is day than month in genitive (16 марта 2023).

I assume that the problem in date utils you are using as dependency for prime calendar, it returns month name cut from full date string (for example for date "16 марта 2023" when you calls smth like date.month.name it returns month name in genitive). I assume, that this issue can be in all languages with cases (word spelling differs depends on context).
Actually I have now idea, how to fix it properly, I've just used durty hack (tested on Russian locale, same would do for other Slavic languages):

class RUMonthNameSpellFix {
    companion object {
        private val namesMapRU = HashMap<String, String>().apply {
            put("марта", "март")
            put("апреля", "апрель")
            put("мая", "май")
            put("июня", "июнь")
            put("июля", "июль")
            put("августа", "август")
            put("сентября", "сентябрь")
            put("октября", "октябрь")
            put("ноября", "ноябрь")
            put("декабря", "декабрь")
            put("января", "январь")
            put("февраля", "февраль")
        }

        fun applyMonthNameFix(monthName: String, locale: Locale) : String {
            return if(locale.language != "ru") // Russian language ISO 639 code
                monthName
            else {
                namesMapRU[monthName.toLowerCase()] ?: monthName
            }
        }
    }
}

And in com.aminography.primecalendar.civil.CivilCalendar.kt (line 19)

    override val monthName: String
        get() = applyMonthNameFix(internalCalendar.getDisplayName(MONTH, LONG, locale), locale)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant