Search code examples
jsonlistsharepoint-onlinemultilingual

Multilingual Column Formatting in Sharepoint List


I am trying to use column formatting JSON and want the txtContent to be different based on the browser/user language. The columns are successfully translating when putting in a different value while using the French browser and the English is retained.

When trying to update the column formatting field with a different version (French), it overwrites the English, so it appears that only the title respects this behavior.

Barring that I am doing something wrong there, I cannot find a way to have the JSON recognize the language with an IF statement.

So is there even a way to do it, or am I forced to do bilingual formatting.

Addendum: I just tried using toLocaleString('2020/10/20 14:00:00') in hopes of it producing a different result between the browser settings and then using that as a comparator, but alas, they were the same.

Potential Solution This is a terrible solution but it seems to work, but is such a hack. =if(indexOf(toString(@now),'heure')==-1,'English','French')


Solution

  • Anything based on dates is unreliable. It is based on various settings that do not necessarily match the user language. For example the Potential Solution is reading the time zone (set by the browser's host operating system, not by SharePoint) and the language of formatting, which I believe is the language of the browser in some browsers. This is not necessarily the same as the currently selected language from the browser's list of accepted languages, and in any case the user's language can be set based on the user's profile rather than by the browser. The formatting of SharePoint-generated dates can depend on the user's locale setting and whether they checked "Always use my personal settings", and these can affect aspects of date formatting, but again the locale may not match the user's language. For JavaScript-generated dates, which I think included "@now", it's based on other factors.

    What I tend to do is create a column called "Yes" and, you guessed it, make it always true. Its displayValue will be "Yes" or "Oui" or "Si" or whatever, based on the user's current display language. Let me know if that helps in your instance.