Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
#812681
There is no REST endpoint to select the language. What do you need it for?

You can create a custom REST endpoint to set the language. For example to set the language to Spanish, you can use this code in your custom endpoint:
Code: Select all
$_SESSION['SYS_LANG'] = 'es';
 
I have created a plugin that you can use to test it:
(23 KiB) Downloaded 491 times
After you import and activate the plugin, you can call it as PUT http://{domain-or-ip}/api/1.0/{workspace}/extrarest/language/{lang}
where {lang} is a variable in the URL, such as:
http://example.com/api/1.0/workflow/ext ... anguage/es
http://example.com/api/1.0/workflow/ext ... uage/pt-BR

You can check the system language with the endpoint GET http://{domain-or-ip}/api/1.0/{workspace}/extrarest/language

Does that work for you?
#812744
jemiris wrote:And one more clarification using rest api sample url :http://example.com/api/1.0/workflow/ext ... uage/pt-BR let's have. Can we set the session in rest api like this $_SESSION['SYS_LANG'] = $lang; will it work
The plugin I gave you has that code:
$_SESSION['SYS_LANG'] = $lang;
Here is relevant code:
Code: Select all
    /**
     * Set the login language in $_SESSION['SYS_LANG']
     * 
     * @url PUT /language/:lang
     * @access protected
     *
     * @param string $lang 
     * 
     * @author Amos Batto <amos@processmaker.com>
     * @copyright Public Domain
     */
    public function putSystemLanguage($lang)
    {  
        if (empty($lang) or empty(trim($lang))) {
           throw new Exception("System language cannot be empty.");
        }
        
        $_SESSION['SYS_LANG'] = $lang;
        
        return null;
    } 
    
    /**
     * Get the login language stored in $_SESSION['SYS_LANG']
     * 
     * @url GET /language
     * @access protected 
     * 
     * @author Amos Batto <amos@processmaker.com>
     * @copyright Public Domain
     */
    public function getSystemLanguage($lang)
    {  
        if (!isset($_SESSION['SYS_LANG'])) {
           throw new Exception("System language for login session does not exist.");
        }
                
        return $_SESSION['SYS_LANG'];
    }
After you import the plugin, look at the code in the file workflow/engine/plugins/extraRest/src/Services/Api/ExtraRest/Extra.php

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]