Answers.Body: <p>Even if the label is different in English and Chinese, the above API with <code>'status_id' =&gt; "Registered",</code> parameter should work fine as it is meant to make the mapping based on <code>name</code> and not label.</p>
  
  <p>Anyway, I think you should be able to use id instead of passing the name of the participant status in the api params. Something like -</p>
  
  <pre><code>$statusOptions = CRM_Event_BAO_Participant::buildOptions('status_id', 'validate');
  ...
  ...your api ...
  ...
    'status_id' =&gt; array_search('Registered', $statusOptions),
  </code></pre>
  
  <p>If the above fails, and you still want to do this by knowing which language is enabled, you can simply use -  </p>
  
  <pre><code>$currentLanguageLocale = CRM_Core_I18n::getLocale();
  </code></pre>
  
  <p>The variable <code>$currentLanguageLocale</code> will hold the locale value of the current language enabled in civi.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-19T06:03:42.990Z
Answers.Text: Can you elaborate on how to get status_id and use it in Participant Api clearly using above quoted code in the question?
Answers.UserDisplayName: harshal
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-19T06:10:39.880Z
Answers.Text: Have already done that. `array_search('Registered', $statusOptions)` will provide you the id of `Registered` participant status.
Answers.UserDisplayName: jitendra - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-19T15:23:36.103Z
Answers.Text: Can I write a custom query to update the Participant Status UPDATE `civicrm_participant` SET `status_id` = '1' WHERE `civicrm_participant`.`id` = 1; will that be work or its a bad idea? and if yes how can I write a custom query in civicrm? @jitendra
  ?
Answers.UserDisplayName: harshal
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-19T04:28:13.953Z
Answers.LastActivityDate: 2019-03-19T04:28:13.953Z
Answers.UserDisplayName: jitendra - fuzion
Body: <pre><code>$result1 = civicrm_api3('Participant', 'create', [
          'id' =&gt; $participant_id,
          'contact_id' =&gt; $contact_id,
          'event_id'   =&gt; $event_id,
          'status_id' =&gt; "Registered",//已登記
        ]); 
  </code></pre>
  
  <p>when I have English enabled in the civicrm, the above API works changes<br> status to Registered from Attended<br>
  When I have Chinese Language enabled in the civicrm, the above API does not change the status <br>
  In the list of Civicrm Participant Status I found that Participant <br>status label is different in Chinese and English(which is obvious)<br>
  But how can we determine if the civicrm page is chinese, As I am using <br>drupal, In drupal we have <br></p>
  
  <pre><code>global $language;
  $lang_code = $language-&gt;language;
  </code></pre>
  
  <p>but in civicrm , how can we determine the language selected from the <br>dropdown and based on that change status_id to be in chinese.<br></p>
  
Tags: <participants><language>
Title: On Language change civicrm api for participant status change does not work as expected
ThreadText: # On Language change civicrm api for participant status change does not work as expected
  
  (Asked by: username_0 on 2019-03-19)
  
  $result1 = civicrm_api3('Participant', 'create', [
          'id' => $participant_id,
          'contact_id' => $contact_id,
          'event_id'   => $event_id,
          'status_id' => "Registered",//已登記
        ]); 
  
  when I have English enabled in the civicrm, the above API works changes status to Registered from Attended
  When I have Chinese Language enabled in the civicrm, the above API does not change the status 
  In the list of Civicrm Participant Status I found that Participant status label is different in Chinese and English(which is obvious)
  But how can we determine if the civicrm page is chinese, As I am using drupal, In drupal we have 
  global $language;
  $lang_code = $language->language;
  
  but in civicrm , how can we determine the language selected from the dropdown and based on that change status_id to be in chinese.
  
  **Tags:** participants, language
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-03-19. Score: 1
  
  Even if the label is different in English and Chinese, the above API with 'status_id' => "Registered", parameter should work fine as it is meant to make the mapping based on name and not label.
  Anyway, I think you should be able to use id instead of passing the name of the participant status in the api params. Something like -
  $statusOptions = CRM_Event_BAO_Participant::buildOptions('status_id', 'validate');
  ...
  ...your api ...
  ...
    'status_id' => array_search('Registered', $statusOptions),
  
  If the above fails, and you still want to do this by knowing which language is enabled, you can simply use -  
  $currentLanguageLocale = CRM_Core_I18n::getLocale();
  
  The variable $currentLanguageLocale will hold the locale value of the current language enabled in civi.
  
  > **Comments:**
  > **username_0**: Can you elaborate on how to get status_id and use it in Participant Api clearly using above quoted code in the question?  
  > **username_1**: Have already done that. `array_search('Registered', $statusOptions)` will provide you the id of `Registered` participant status.  
  > **username_0**: Can I write a custom query to update the Participant Status UPDATE `civicrm_participant` SET `status_id` = '1' WHERE `civicrm_participant`.`id` = 1; will that be work or its a bad idea? and if yes how can I write a custom query in civicrm? @jitendra ?  
  
  ---
  
  