Contents

Localisation

 

By specifying the locale parameter during SDK initialisation as described below, you can change the language and formatting of text displayed to better suit the needs of your international customers. Such changes are applied to field names, buttons (e.g. “Pay”) and notification messages displayed to the customer during the checkout process (e.g. Success or Declined). Read on to learn how.

 


 

Locale for form elements

Please refer to the following Swift example to learn how to translate form elements, such as field names and button labels. You can opt to include the additional field locale when configuring the instance. Your app will use the value of this field when rendering the checkout form, to ensure the correct language is displayed to the customer.

locale requires a language and country to be specified, in the format shown below. We support the following locales:

locale value Description
cy_GB Welsh, United Kingdom
da_DK Danish, Denmark
de_DE German, Germany
en_US English, United States
en_GB English, United Kingdom
es_ES Spanish, Spain
fr_FR French, France
nl_NL Dutch, The Netherlands
no_NO Norwegian, Norway
sv_SE Swedish, Sweden

TrustPayments.instance.configure(locale: Locale(identifier: "en_GB"), translationsForOverride: nil)

Info
If a locale is not submitted, the checkout uses the default value provided by the device. If the device language is not supported, the checkout then defaults to English (United Kingdom).

 


 

Locale for gateway response

By also updating the payload within the JWT to include the locale field, you can update your checkout to translate response messages returned by the gateway during the payment session.

locale requires a language and country to be specified, in the format shown below. We support the following locales:

locale value Description
cy_GB Welsh, United Kingdom
da_DK Danish, Denmark
de_DE German, Germany
en_US English, United States
en_GB English, United Kingdom
es_ES Spanish, Spain
fr_FR French, France
nl_NL Dutch, The Netherlands
no_NO Norwegian, Norway
sv_SE Swedish, Sweden

let claim = TPClaims(iss: keys.merchantUsername,
                     iat: Date(timeIntervalSinceNow: 0),
                     payload: Payload(locale: "en_GB",
                                      accounttypedescription: "ECOM",
                                      sitereference: keys.merchantSiteReference,
                                      currencyiso3a: "GBP",
                                      baseamount: 1100))

Info
If a locale is not submitted, the checkout uses the default value provided by the device. If the device language is not supported, the checkout then defaults to English (United Kingdom).

 


 

Custom translations

You can specify custom translations for elements on the checkout form that will override the default text displayed.

Tick
Advantages:

  • Provide alternative wording to the default phrases returned to better reflect your brand’s voice (e.g. re-wording the default error messages returned to customers).
  • Provide additional info that may be specific to your business (e.g. including an order reference).

 

To specify custom translations, you will need to specify LocalizableKeys in the SDK initialisation. The following example shows how to provide custom translations for the pay and back buttons, in the French and English languages:


TrustPayments.instance.configure(username: "username", gateway: .eu, environment: .staging, locale: Locale(identifier: "en_GB"), translationsForOverride:
	[
		Locale(identifier: "fr_FR"):
		[
			LocalizableKeys.PayButton.title.key: "Payez maintenant!",
			LocalizableKeys.Navigation.back.key: "Retourner"
		],
		Locale(identifier: "en_GB"):
		[
			LocalizableKeys.PayButton.title.key: "Pay Now!",
			LocalizableKeys.Navigation.back.key: "Go back"
		]
	]
)

 

List of all LocalizableKeys (including default text)


public enum LocalizableKeys {
    // MARK: Pay Button
    public enum PayButton: LocalizableKey {
        case title
    }



    // MARK: DropIn View Controller
    public enum DropInViewController: LocalizableKey {
        case successfulPayment
    }



    // MARK: Errors
    public enum Errors: LocalizableKey {
        case general
    }



    // MARK: CardNumberInputView
    public enum CardNumberInputView: LocalizableKey {
        case title
        case placeholder
        case error
        case emptyError
    }



    // MARK: CvcInputView
    public enum CvcInputView: LocalizableKey {
        case title
        case placeholder3
        case placeholder4
        case placeholderPiba
        case error
        case emptyError
    }

    // MARK: ExpiryDateInputView
    public enum ExpiryDateInputView: LocalizableKey {
        case title
        case placeholder
        case error
        case emptyError
    }

    // MARK: AddCardButton
    public enum AddCardButton: LocalizableKey {
        case title
    }

    // MARK: Alerts
    public enum Alerts: LocalizableKey {
        case processing
    }
}