Localisation

  Last updated: 

 

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

 

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
it_IT Italian, Italy
nl_NL Dutch, The Netherlands
nb_NO Norwegian, Norway
no_NO Norwegian, Norway
sv_SE Swedish, Sweden

 

(Swift)

TrustPayments.instance.configure(
username: "username",
gateway: .eu,
environment: .staging,
locale: Locale(identifier: "en_GB"),
translationsForOverride: nil
)

If a locale is not configured, the payment form checkout text will attempt to use the default language value provided by the device. If the device language is not supported, the payment form checkout text 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
it_IT Italian, Italy
nl_NL Dutch, The Netherlands
no_NO Norwegian, Norway
sv_SE Swedish, Sweden

 

(Swift)

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

If a locale is not submitted in the JWT payload, the responses from the Trust Payments gateway uses the default value English (United Kingdom). If the locale specified in the JWT payload is not a gateway supported locale, and invalid field error will be returned.

 

Custom translations

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

This also allows you to 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).

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:

(Swift)

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)

(Swift)

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
}
}
Was this article helpful?
0 out of 0 found this helpful