Has anyone figured out how to manage multi-lingual custom field display names? I can only get them to work clunkily on layouts.
Hello bdbd,
To manage multiple languages, I created a global table named “Label” with a multi-valued field for the number of labels needed, also named ‘Label’; each label will therefore be in the form “Label::label[n]”. I also created another table named “LanguageLabel” containing as many records as languages and a key which value is the language index each with a multi-valued field for the number of labels needed. To change the language, simply update the multivalued field in the “Label” table with the language number record from the “LanguageLabel” table.
I hope that was clear.
A similar technique to @bertrand is used by @nicklightbody in his work. If you download his performance demo file you'll see the construction there.
Sorry but no!
Language tables are an old construct. I am familiar with many variations of this construct. I am looking for non-data approaches that can work with the new FileMaker 26 custom field display names feature.
Not sure if this is a good option performance-wise, as this approach would require JSON functions for display purposes. I would probably benchmark it before using it extensively. But you can simply add key/values to the field display name object like this: "label.en":"My label", "label.fr":"Mon étiquette". On the layout, you would have a layout calc set to: JSONGetElement ( FieldDisplayNames ( Get ( FileName ) ; GetFieldName ( myField ) ) ; "label." & language_code ). Where language_code is whatever represents current language in your session (global field, global variable, persistent value, etc).
Please note that this is a proposed approach, not something that I tested.
I’ve only used them as place holders which are a simple replacement for the field name.
Managing several languages might need tooling/processes outside the UI.
Thanks to everyone for your suggestions. Shoutout to @Bobino for the solution I chose to implement.
The "Customize field display names" option in the "Advanced Options" in field definitions expects a calculation that results in a JSON text. The JSON structure is a simple list of JSONString values. Keys can be anything, though those starting with "fm_" are reserved and serve specific functions within FileMaker (see FileMaker's documentation for more information).
The implementation I chose was to nestle multiple JSON definitions in a case statement, where each test results in selecting a locale-specific JSON. Example below:
Case (
getLocaleCustomFunction = "fr"; // French
JSONSetElement (""; "fm_common"; "Valeur francophone"; JSONString);
// Default is en (English) if getLocaleCustomFunction is empty or en.
JSONSetElement (""; "fm_common"; "English Value"; JSONString)
)
I opted to use a custom function to obtain the locale — more customizable that way.
I played a little devil's advocate. https://fmdojo.com/shared-chat/a68fd5c45b296add48fbbd2c1851d9cb
FieldDisplayNames() really is a great new feature. So flexible because it's a calculation
I do wish that there was a better way to display custom labels on layouts though. Currently it's a button bar or layout calculation (but beware those don't update if you change field names) with this calc (or a CF)
Ugh:
JSONGetElement ( FieldDisplayNames ( "" ; GetFieldName ( MyTable::myField ) ) ; "fm_common" )