Flexmonster - Localization

Demos

by Flexmonster Pivot Table

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<button onclick="setLocalization('en')">EN</button>
<button onclick="setLocalization('fr')">FR</button>
<button onclick="setLocalization('it')">IT</button>
<button onclick="setLocalization('es')">ES</button>
<button onclick="setLocalization('pt')">PT</button>
<button onclick="setLocalization('zh')">ZH</button>
<button onclick="setLocalization('uk')">UK</button>

<div id="pivot-container"></div>

CSS

@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);

JavaScript

const pivot = new Flexmonster({
  container: "#pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  height: 550,
  toolbar: true,
  report: {
    dataSource: {
      type: "csv",
      filename: "data/data-en.csv"
    },
    slice: {
      rows: [
        {
          uniqueName: "Country"
        },
        {
          uniqueName: "Category"
        }
      ],
      columns: [
        {
          uniqueName: "Color"
        },
        {
          uniqueName: "[Measures]"
        }
      ],
      measures: [
        {
          uniqueName: "Price",
          aggregation: "sum",
          format: "currency"
        },
        {
          uniqueName: "Quantity",
          aggregation: "sum"
        }
      ]
    },
    options: {
      useCaptionsInCalculatedValueEditor: true
    },
    formats: [
      {
        name: "currency",
        currencySymbol: "$",
        thousandsSeparator: ",",
        decimalSeparator: ".",
        decimalPlaces: 2
      }
    ]
  },
  beforetoolbarcreated: customizeToolbar,
  shareReportConnection: {
    url: "https://olap.flexmonster.com:9500"
  }
});

const pdfFonts = {
  en: "https://cdn.flexmonster.com/fonts/NotoSans-Regular.ttf",
  fr: "https://cdn.flexmonster.com/fonts/NotoSans-Regular.ttf",
  it: "https://cdn.flexmonster.com/fonts/NotoSans-Regular.ttf",
  es: "https://cdn.flexmonster.com/fonts/NotoSans-Regular.ttf",
  pt: "https://cdn.flexmonster.com/fonts/NotoSans-Regular.ttf",
  zh: "https://cdn.flexmonster.com/fonts/NotoSansCJKsc-Regular.ttf",
  uk: "https://cdn.flexmonster.com/fonts/NotoSans-Regular.ttf"
};

let currentLang = "en";

function setLocalization(lang) {
  currentLang = lang;
  const currentReport = pivot.getReport();
  currentReport.dataSource = {
    type: "json",
    filename: `https://cdn.flexmonster.com/data/localized/data-${lang}.json`,
    mapping:...