Localization can be described as the process of adapting your application to better fit the language and culture of the end users. Making it easier for the users to understand and use an application is integral to an effective workplace. There are many ways of integrating localization into your application. One of the most basic but important ways is enabling users to choose the language of the application. Let's explore one way to achieve this in Claris FileMaker. Includes a video and sample file.
Application
To demonstrate this functionality, we'll use a small application for the data entry of products. You can download the application from this article (located at the end of the article) and follow along.
As you can see, the user interface is currently in English. Let's head over to the "Setup" tab and see what options our users have.
From the Setup screen, the users get access to the application's UI dictionary. From here, one can set different keywords and specify the values in the languages supported. Usually, this setup window is reserved for admin users or developers, as changes made here will affect the entire application.Â
When a new record is created, the users can enter any value they want as the key. This value needs to be unique, or else it will change the other value that has the same key. Then enter the values for the different languages. The yellow dot on the left indicates that this record has not been synched into the system yet.
Once the values have been entered, click the "Update" button, and the values will synchronize in the system. The dot on the left will change to green to indicate that the value is ready to use.
Users can also change their preferred language with the dropdown on the top-right. This will immediately change the language of all the UI features of the application.
How Does It Work?Â
Let's take a look at how this works. This system has three core parts:Â
A global JSON variable generated upon opening the fileÂ
A custom function to get the labels in the correct languageÂ
Using button bars as labels to allow us to change their valuesÂ
The Global Language JSON
In order to allow access to the values to all layouts, a global JSON object is generated when the file is first opened. Here's a shorter version of the JSON generated.
{ "language" : "English", "dictionary" : { "sync" : { "English" : "Sync", "Spanish" : "Sincronizar" }, "testText" : { "English" : "Test text", "Spanish" : "Texto de prueba" }, "userName" : { "English" : "Username", "Spanish" : "Nombre de Usuario" } } }
As you can see in the JSON, we save the language that is selected and a dictionary of the records. We can go ahead and get the value that we need by grabbing the value of the key at the selected language.Â
FileMaker has excellent support for working with JSON data, so creating this JSON object is fairly simple. Here's the script used to generate it.
And here is a closer view at the Set Variable step on line 17:
JSONSetElement ( $$languageJSON ; [ "dictionary." & DICTIONARY: :key & "." & "English"; DICTIONARY: :englishValue ; JSONString ]; [ "dictionary." & DICTIONARY: :key & "." & "Spanish"; DICTIONARY: :spanishValue ; JSONString ] )
The Custom Function
This custom function is a way to make it more convenient for the developer to use the functionality throughout the system. It is in charge of querying the JSON object for the value of the specified key on the currently selected language.
//Name: getLanguage(key) //Parameter: key Let( [ vLanguage = JSONGetElement($$languageJSON; "language"); vPath = "dictionary." & key & "." & vLanguage; vValue = JSONGetElement($$languageJSON; vPath) ]; vValue )
A sample call to this function would look like this:
getLanguage("nameLabel")
Button Bars as Labels
Using a button bar with a single segment as a label, we can dynamically set the displayed text. In our case, we make a call to our custom function to get the value we want in the correct language.
Updating the JSON Object
There are two situations that we want to handle:
New values
Updated values
One simple way to handle both of these cases is to simply create the JSON Object again when new values are added or updated. To do that, we simply attach the script that creates the JSON to the "Sync" button.
The creation of the JSON is quick enough that remaking it won't really affect the application's performance.Â
ConclusionÂ
Localization is very important when your application is used by people speaking different languages . One very important aspect of localization is adding the ability for users to change the language of the application. We demonstrated how to do this by creating a global dictionary with the labels for the application and making a custom function to query values. We also used button bars as labels as they support dynamic labels.Â
If you would like to learn more about localization in FileMaker or explore possible ways in which localization can make your business more effective, contact our team at DB Services and we'll gladly help you find the best solution for your business.
Did you know we are an authorized reseller for Claris FileMaker Licensing?
Contact us to discuss upgrading your Claris FileMaker software.
Download the FileMaker Localization File
Please complete the form below to download your FREE FileMaker file.