Select the data language with the REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
17-06-2020 09:55 AM - edited 07-12-2020 10:15 AM
query user {
personSystem(filter:{name:"Thomas"}) {
id
name
dataLanguage {
...on Language {
language:languageCode
languageId:id
languageName:name
}
}
}
}
In HOPEX the data can be inputted in different languages ( English, French, Spanish, Italian, German...). When connected by the GraphQL REST API it is possible to select the data language.
Query data in the current data language
By default all the queries are performed in the current data language.
- For instance the following query will return the name of the application in English.
Query | Result |
|
|
- To know the current language execute the following query :
Query | Result |
|
|
Query data in a selected data language
When requesting the data you can force the language of the return data for all translatable fields (name, comment...). The selection of the language is done by its code : EN, DE, JA, FR, ES, NL, IT...
In one query you can get the data in a given language or several languages.
- For instance the query below will return the name of the application in English, French and Italian. As they can be only one field with name we create alias of the name. As seen in the example the translation may not be available and an empty string is returned.
Query | Result |
|
|
Theses request do not change the default language of the user. Any next query done without defining the language is returned in the default language.
Change the current data language
To change the current data language you need to update the user context. For that you need to execute a graphQL mutation on the context.
- In the example below the context will be changed to French.
Query | Result |
|
|
Change data language for a given user
Aside from the current user it is also possible to update the data language of group of user.
Query to know the language of a given user
You can query the user to understand which language they have by default. If the return value is blank the default language is the same as the installation.
Query | Result |
|
|
Mutation to update the language of a given user
You can set the language of a given user by it's ID.
Query | Result |
|
|
Get the list of available data language
To know the possible value of the language code available you can query graphQL.
query availableLanguage {
language(filter:{id:"I9o3by0knG00"}) {
language_SpecializedLanguage {
language:languageCode
languageId:id
languageName:name
}
}
}
You may have to to it on the MetaModel schema so that query can work.
How to add data language and see them in the API
The list of available data language depends on the options defined in HOPEX. Check the available language in the installation options or environment options :
For more details on how to add data language read the full documentation here :
