Adyen / adyen-android

Adyen Android Drop-in and Components
https://docs.adyen.com/checkout/android
MIT License
119 stars 66 forks source link

Cannot override translations for Drop In #489

Closed mohadian closed 2 years ago

mohadian commented 2 years ago

Describe the bug It seems we cannot override the translations on Adyen Drop-in. More specifically, the "Credit Card" seems to be hardcoded and the SDK is not using the string resources for it. Also, the string "Credit card" in the string resources is the same for all the locales. I was wondering if this is intentional?

To Reproduce Steps to reproduce the behavior: Open the online payment Drop in try to add a new Card. Notice the title is always appear as Credit Card in all the languages.

Expected behavior The text should be translated for different locales or it should be possible to override it.

Screenshots

Screenshot 2021-09-16 at 11 54 00 Screenshot 2021-09-16 at 11 53 46

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Would you please direct me to place in the documentation which covers the Customising the DropIn? ( strings and colors)

jreij commented 2 years ago

Hi, there are 2 types of localization, native (overriding string resources in the app) and backend (localizing the API responses), both are completely possible. This "Credit Card" label, in both the payment methods and the credit card screen, actually comes from the API response.

To customize that, your backend needs to pass the Shopper Locale attribute in the request body.

As for other (non API) labels, you can override the string resources in xml but I see that you already did that 🙂 Same for the colors and styles.

heikkihautala commented 2 years ago

Is there any documentation on how to override string resources? I'd like to override the pay_button resource since we're only tokenizing the card and not actually paying anything yet.

We're using sdk version 4.3.0.

jreij commented 2 years ago

@heikkihautala there are no docs for this currently but it's an item in our queue, along with some general localization improvements.

At the moment what you can do is take a look at all the strings.xml files in each module and find what you need. For example: Drop-in: https://github.com/Adyen/adyen-android/blob/develop/drop-in/src/main/res/values/strings.xml Card: https://github.com/Adyen/adyen-android/blob/develop/card/src/main/res/values/strings.xml And so on...

caiofaustino commented 2 years ago

I think what he means is just how to make the override.

You just need to define the pay_button string in your project, it will take priority over the one defined in the SDK.

heikkihautala commented 2 years ago

I tried adding the same resource on our strings.xml file: <string name="pay_button">Submit</string> but the card component still shows "Pay" in the button ("Maksa" in finnish).

jreij commented 2 years ago

Does the button show Pay along with a certain amount, or just Pay?

heikkihautala commented 2 years ago

Just "Pay" in finnish ("Maksa") as I haven't defined an amount.

In values/strings.xml I have: <string name="pay_button">Submit</string>

And in values-fi/strings.xml I have: <string name="pay_button">Lähetä</string>

If the device language is set to english, the button says "Submit" correctly, but when I change the language to finnish, it says "Pay" and not "Lähetä".

jreij commented 2 years ago

Can you try to put it in values-fi-rFI/strings.xml?

heikkihautala commented 2 years ago

That worked. Thanks 👍

heikkihautala commented 9 months ago

How could we change the card form title Credit card to something else? That text comes from the /paymentMethods response, so I guess it cannot be overridden in the app. User could input debit card info also, so Credit card is not accurate. We'd like to change it to Payment card.

EDIT: Found the answer: https://github.com/Adyen/adyen-ios/issues/218#issuecomment-693251161.