Skip to content

Localization is working partially #1768

@kacpr

Description

@kacpr

Description

Strings in dropin are translated partially.
When shopperLocale is set to:

  • "pl_PL" - strings are translated partially (mix of pl and eng) - see attached screenshots with "pl_PL" suffix
  • "pl-PL" - strings are translated correctly - see attached screenshots with "pl-PL" suffix.

Backend uses sessions integration flow.
Backend set shopperLocale to "pl_PL".
Android app receives CheckoutSession with SessionSetupResponse.shopperLocale set to "pl_PL".

Since strings in dropin are partially translated, I believe there are multiple call sites and methods that try to obtain locale and this flow isn't bulletproof.

Expected behavior (possible solutions):

  • Unify / fix flow of obtaining locale
  • Handle both formats (with "_" and "-") of shopperLocale properly or inform about invalid format
  • Consistent translation

Steps to Reproduce

  1. I am able to consistently reproduce this issue: Yes
  2. Steps to reproduce the issue:
    1. Get CheckoutSession from SessionSetupResponse.createSession()
    2. Create copy of returned CheckoutSession from step i with overwritten SessionSetupResponse.shopperLocale ("pl_PL")
    3. Start payment:
        DropIn.startPayment(
            dropInLauncher = dropInLauncher,
            checkoutSession = checkoutSession,
        )
    
  3. Screenshots:
    "pl_PL" (check Blik z kodem and Karta bankowa):
screen_1_pl_PL screen_2_pl_PL screen_3_pl_PL screen_4_pl_PL

"pl-PL":

screen_1_pl-PL screen_2_pl-PL screen_3_pl-PL screen_4_pl-PL

Code Snippets

Maybe this will be helpful:
during debugging I found that those methods weren't using / returning correct locale:

checkout-core:5.6.0
LocaleUtil
    fun fromLanguageTag(tag: String): Locale {
        return Locale.forLanguageTag(tag)
    }
checkout-core:5.6.0
LocaleProvider
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
class LocaleProvider {

    fun getLocale(context: Context): Locale {
        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            context.resources.configuration.locales[0]
        } else {
            @Suppress("DEPRECATION")
            context.resources.configuration.locale
        }
    }
}
components-core:5.6.0
ContextExtensions:
fun Context.createLocalizedContext(locale: Locale): Context {
    val configuration = resources.configuration
    val newConfig = Configuration(configuration)
    newConfig.setLocale(locale)

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        val localeList = LocaleList(locale)
        LocaleList.setDefault(localeList)
        newConfig.setLocales(localeList)
    }

    return createConfigurationContext(newConfig) ?: this
}

Integration Information

  1. Server-side integration: Sessions
  2. Client-side integration: Drop-in
  3. SDK version: 5.6.0
  4. Android version(s) where issue occurs: API 34
  5. Device model(s) where issue occurs: emulator - pixel 5, google play services, API 34, arm64. System language: polish (default), english (US).

Additional Context

Related issues:
Adyen/adyen-react-native#15
#1558
#680

Keywords: localization, translations, language, resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementIndicates a new feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions