diff --git a/CRM/Twingle/Submission.php b/CRM/Twingle/Submission.php
index b96c64e..2c2a282 100644
--- a/CRM/Twingle/Submission.php
+++ b/CRM/Twingle/Submission.php
@@ -200,6 +200,14 @@ class CRM_Twingle_Submission {
}
}
+ // Prepare values: language.
+ if (!empty($contact_data['preferred_language'])) {
+ $mapping = CRM_Core_I18n_PseudoConstant::longForShortMapping();
+ // Override the default mapping for German.
+ $mapping['de'] = 'de_DE';
+ $contact_data['preferred_language'] = $mapping[$contact_data['preferred_language']];
+ }
+
// Pass to XCM.
$contact_data['contact_type'] = $contact_type;
$contact = civicrm_api3('Contact', 'getorcreate', $contact_data);
diff --git a/README.md b/README.md
index 0e2e580..9b4fec0 100644
--- a/README.md
+++ b/README.md
@@ -113,10 +113,11 @@ The action accepts the following parameters:
| `user_street` | String | The street address of the contact | | |
| `user_postal_code` | String | The postal code of the contact | | |
| `user_city` | String | The city of the contact | | |
-| `user_country` | String | The country of the contact | [ISO 3166-1 Alpha-2 country codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) | |
+| `user_country` | String | The country of the contact | A [ISO 3166-1 Alpha-2 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) | |
| `user_telephone` | String | The telephone number of the contact | | |
| `user_company` | String | The company of the contact | | |
| `user_extrafield` | String | Additional information of the contact | | |
+| `user_language` | String | The preferred language of the contact. | A [ISO-639-1 2-digit language code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | |
| `campaign_id` | Integer | The CiviCRM ID of a campaign to assign the contribution | A valid CiviCRM Campaign ID. This overrides the campaign ID configured within the profile. | |
You may also refer to
diff --git a/api/v3/TwingleDonation/Submit.php b/api/v3/TwingleDonation/Submit.php
index 4025f97..abea337 100644
--- a/api/v3/TwingleDonation/Submit.php
+++ b/api/v3/TwingleDonation/Submit.php
@@ -224,6 +224,13 @@ function _civicrm_api3_twingle_donation_Submit_spec(&$params) {
'api.required' => 0,
'description' => E::ts('The company of the contact.'),
);
+ $params['user_language'] = array(
+ 'name' => 'user_language',
+ 'title' => E::ts('Language'),
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'api.required' => 0,
+ 'description' => E::ts('The preferred language of the contact. A 2-digit ISO-639-1 language code.'),
+ );
$params['user_extrafield'] = array(
'name' => 'user_extrafield',
'title' => E::ts('User extra field'),
@@ -393,6 +400,7 @@ function civicrm_api3_twingle_donation_Submit($params) {
'user_birthdate' => 'birth_date',
'user_email' => 'email',
'user_telephone' => 'phone',
+ 'user_language' => 'preferred_language',
'user_title' => 'formal_title',
'debit_iban' => 'iban',
) as $contact_param => $contact_component) {