Application language settings

4
  Hi everyone,  I want to show some pages in my app in different languages. Can I select and display different languages ​​on the same page instead of making separate pages for the languages ​​I want to show? How can I do that? Any help is much appreciated!!!   Thanks in advance,   Halil Kanat
asked
3 answers
3

Hi! Halil,

As I understand it, you need to use translation service. https://academy.mendix.com/link/modules/451/lectures/3593/-4.1-Understanding-Translation-Service

I think this link will help you. I hope it solves the problem.
 

Regards,

Mehmet

answered
1

Hi Halil Kanat,

We can have different languages added to our app. 

First we can add the language on the mendix toolbar (language >language settings > add )

then, in the right corner of the app we can switch between languages and translate the information on our pages

 

please see the documentation for more detail information:
https://docs.mendix.com/howto8/collaboration-requirements-management/translate-your-app-content/

https://academy.mendix.com/link/modules/187/lectures/1466/7.3-Translation-Tools



Please, let me know if the information was useful

 

 

 

answered
1

Dear Halil, 

Just adding my bit – After you have added languages and translations (ctrl + L and ctrl + shift + L are your friends), in order for user-selected language to become active you need to give the users a list (System.Language) and upon click of an item do this:

  • Associate the chosen $Language to $currentUser (+commit)
  • Refresh the $currentSession using a JavaScript action – this will trigger a reload of all elements in the newly set language.
     

This is best done from a Nanoflow that includes a Microflow to change the actual language.

Here is an example of a Nanoflow that sets the User's language to Dutch – mind you – if you use an input parameter based upon a System.Language list-item, this will be more efficient ;-)

 

When using an input parameter, just use System.Language/LanguageCode as the parameter for the Microflow SUB_Language_SetToInput, or pass the System.Language itself as a parameter – we chose to use the string variable due to access rights.

The Microflow is very simple:

It finds the System.Language with the matching /LanguageCode from the Db, and if found, associates to User (+Commit). If we now refresh the session, the language will be loaded automatically. 

Going back to the final activity in the Nanoflow: this is a JavaScript action doing a single thing: it refreshes the session, but keeps the data active in the session available. Here is the code:

// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { Big } from "big.js";

// BEGIN EXTRA CODE
// END EXTRA CODE

/**
 * Triggers a refresh of the page, while keeping the content of the page.
 * @returns {Promise.<void>}
 */
export async function JsA_RefreshPage_KeepContent() {
	// BEGIN USER CODE
    mx.reloadWithState(); //reloads the page, keeps the content in the page as is
                          //for Native context use mx.reload();
	// END USER CODE
}

Here is an example of what your Language Selection List could look like:

 

Good luck translating and hope this helped. If it did, please mark as the correct answer ;-)

Best regards,

Wouter

answered