Configure and implement multi language.
Overview
Feature | PSP | OSP | Emails | Invoices | Billing Portal | Chargifyjs | Advanced Billing Admin UI |
---|---|---|---|---|---|---|---|
Supports Multi Language | Yes | Yes | Yes | Yes | No | n/a | No |
Code | Some code | Some code | No code | No code | n/a | n/a | n/a |
Implementation Path | JS | JS | Email variables + you write the email content (sample provided) | Configure invoice language setting | n/a | Make your app multi-lingual | n/a |
Summary
- Feature
- All signup methods
- You Need
- An understanding of how customers subscribe to your services, and your post-signup flow (if any).
- Code
- No
- Difficulty
- ◉◉◎◎◎
Implementation
1. Set locale on customer creation
HTML
The locale value determines the language. You can set it when creating the customer, or when creating the customer+subscription simultaneously (most common).
1. When linking to your PSP, prepopulate the
2. When your page loads, the language will be set in the background, it is not visible to the user. To test, fill out your payment form and submit. When you visit the customer record, you will see the locale set accordingly.
locale
variable. For example, if you pass French, your PSP url will look like pspurl?locale=fr
.<!-- Syntax: PSPLINK?locale={locale}&reference=123?first_name=Tommy&last_name=Emmanuel-->
<a href="https://chargify-sandbox-141.chargifypay.com/subscribe/yy2xt8wtsnm2/basic_plan?locale=fr&reference=123&first_name=Tommy&last_name=Emmanuel">
<button type="button" class="w-100 btn btn-lg btn-primary">Subscribe to Pro</button>
</a>
2. When your page loads, the language will be set in the background, it is not visible to the user. To test, fill out your payment form and submit. When you visit the customer record, you will see the locale set accordingly.
If creating a subscription with the API and Chargifyjs, you would submit the language by passing
locale
within the customer_attributes
object.// EXAMPLE: Chargifyjs for Credit Cards - Create Subscription with Product
// ENDPOINT: POST /subscriptions.json
// DOCS: https://developers.chargify.com/docs/api-docs/b3A6MTQxMDgzODg-create-subscription
// REQUEST BODY
{
"subscription": {
"product_handle": "gold-plan",
"customer_attributes": {
"first_name": "Christopher",
"last_name": "Adil",
"email": "christopher.adil@example.com",
"organization": "Varity LLC",
"locale": "fr" //a valid locale
},
"credit_card_attributes": {
"chargify_token": "tok_mzvtmcv2hgtxj9sb7qq5kphc",
"payment_type": "credit_card"
}
}
}
If creating the customer in the Advanced Billing Admin UI, set the locale when creating the customer.
2. Configure language on invoices
Use these steps from the configure invoices guide.
3. Configure language on emails
If you set the customer
Customer Locale
Example showing French, German, and English, using if, elsif, and else.
locale
on the customer record, you can access the value within your emails, to determine which email content the customer receives. Customer Locale
Example showing French, German, and English, using if, elsif, and else.
{% if customer.locale == "fr" %}
Bonjour {{customer.first_name}}
{% elsif customer.locale == "de" %}
Hallo {{customer.first_name}}
{% else %}
Hello {{customer.first_name}}
{% endif %}
4. Configure language on PSPs
JS
Use the resource from this step, from the configure PSP guide.