What triggers an unsaved calculation field to revaluate

Hello all,

I have an app that displays some fields according to the selected language. There are two languages, French and English. When the user change language, I need to update the display according to the new set language. The values to update are fields in a table.

For example in a table I have:

Content_fr Content in French, Text field
Content_en Content in English, Text field
Content Content, calculation that returns a text

The calculated field is set to

if ( $$Language = "Fr" ; Content_fr; Content_en )

and not saved. The selected language is saved in a global variable.

When the user changes the language, Content field value is not changed. I came to the conclusion that the change in the value of a global variable does not trigger the recalculation of the calculated field. Am I right ? If so that means I would need to have the language saved in a field of the same table, for example a global field. Since I don't want to give users permission to write to tables. would that be an issue ? Are there other way to achieve my goal ? This app runs on an iPad.

Thanks

Fields are unaware when script or global variables change. Refreshing a window causes unstored calculation fields to re-evaluate.

1 Like

Refreshing the window does not work. Don't forget that the calculated fields are not stored. I do get weird results. This is the Window:

  • When I change the language,

    • I want to change the buttons' labels (they come from a list in a global variable, and the list itself is created by a script that runs ExecuteSQL to pick contents from a nonsaved calculated field)

    • And I want to change the text to the new language, again that comes form a non calculated field

I am clueless...

Well, I said the calculated fields were unstored, but the ckeckbox was not checked. Now it works, event if I don't do a Refresh Window. All I need to do is Resfresh Object, that is the Button bar and the field.

Dumb me !

EDIT on Feb 24th 2023

I can't set this message as the solution/answer because I am the creator of this thread.

How did you come to this solution in the first place? Calculations on every layout might be challenging?!

I have a table for interface texts
Number - used for identifying a repetition later on loading text
LanguageID - every text in every language has one entry in the table
Text
Type - e.g. button, label, message, value for picklist

Depending on the application it might hold thousands of entries.

Next I generated one global stored text field in the applications session table named sTxt with 3000 repetitions.

The repetitions are filled once while starting the session and can be reset if the user wants to change the language. This happens via script in a loop iterating through the table selecting the needed text by number and language match.

These are referenced everywhere in the application.

1 Like

Would you be able to upload an example file of this kind of translations handling/usage?

just a simplified demo of the system

LanguageSwitch.zip (94.1 KB)

2 Likes

This solution works on a single layout. There are many subjects though. With 2 button bars I select a Topic and a Subject, that results in a text to be displayed. This text as well as the buttons on the Subjects button bar ahev to be displayed in two languages, either English or French.

For more details, see Button bar active segment by calculation - Questions - the.fmsoup.org - Independent FileMaker Forum. Help, Discussions & Answers for Developers and Users

Finally had time to look at this. Looks quite nice. Doesn't pollute variable space (data viewer) as much as having global variables for each translated label. Although slightly more work to remember which is the correct repetition when setting a label for some element.