Back to column formats
Column formattingSharePoint Online

Number Localization

This sample demonstrates changing text output based on the @lcid token. This allows you to provide localized text within your format ensuring that users in various regions can use your formats without issue.

Number Localization formatting preview
Sample preview · View original image

Copy. Apply. Make it yours.

Get this format

1 definition

Review the requirements below, then paste this JSON into the matching formatting panel. Show me where.

Use your list's internal column names and replace any tenant-specific URLs or flow IDs. Formatting is presentation, not a way to secure data.

Column formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "=if(length(@currentField),@currentField,if([$ThreatLevel]>=1,if(@lcid==1031,'Ihr werdet mit Füßen getreten werden!','Ye shall be trampled!'),if([$ThreatLevel]>=.75,if(@lcid==1031,'Ich spüre Mord in eurer Zukunft.','I sense murder in your future.'),if([$ThreatLevel]>=.5,if(@lcid==1031,'Unsere Scheuklappen sind ab und wir beobachten euch!','Our blinders are off and we are watching you!'),if([$ThreatLevel]>=.25,if(@lcid==1031,'Schnupftabak schnupfen!','Snuffle snuffle snort!'),if(@lcid==1031,'Hab einen schönen Tag!','Have a great day!')))))",
  "style": {
    "font-weight": "=800*([$ThreatLevel]+.25)"
  },
  "attributes": {
    "class": "=if([$ThreatLevel]>=1,'ms-fontColor-redDark',if([$ThreatLevel]>=.75,'ms-fontColor-red',if([$ThreatLevel]>=.5,'ms-fontColor-orange',if([$ThreatLevel]>=.25,'ms-fontColor-orangeLight','')))"
  }
}

From the contributor

How to use this sample

Summary

This sample demonstrates changing text output based on the @lcid token. This allows you to provide localized text within your format ensuring that users in various regions can use your formats without issue.

screenshot of the sample

View requirements

This format can be applied to any column. It expects a number column called ThreatLevel to be part of the view.

Sample

Solution Author(s)
number-localization.json Chris Kent

Version history

Version Date Comments
1.0 May 12, 2022 Initial release

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.


Additional notes