Language localization
Our pivot table can easily be translated into different languages. This article describes the process of language localization for WebDataRocks reporting component.
Available localizations
Localization files for new languages can be added by creating a new pull request on GitHub. Our team highly appreciates any help.
Create a custom localization file
Follow the steps below to create your own localization file based on our template:
Step 1. Download template JSON file. It contains all labels that are used in WebDataRocks and English values for them.
Step 2. Translate values into the language you want.
For example, you want a Spanish localization. You start from replacing the first label-value pair from the template ("flatHierarchyBox": "Select and arrange columns"
) with its Spanish equivalent ("flatHierarchyBox": "Seleccionar y organizar columnas"
) and keep on the same way with the whole file (e.g., check Spanish translated sample).
Localize a specific report
To set a specific language for a report, add a report.localization
property with the necessary localization:
Set the localization as a URL to the file
const report = {
dataSource: {
filename: "https://cdn.webdatarocks.com/data/data.csv"
},
// Replace this file with your own localization file
localization: "https://cdn.webdatarocks.com/loc/es.json"
};
Set the localization as an inline JSON object
const report = {
dataSource: {
filename: "https://cdn.webdatarocks.com/data/data.csv"
},
// Replace the translation below with your own labels
localization: {
fieldsList: {
flatHierarchyBox: "Seleccionar y organizar columnas",
hierarchyBox: "Seleccionar dimensiones",
filterBox: "Filtros del Informe",
// Other labels
}
}
};
Set localization for all reports
If you want to set one language for all reports, add a global
object with localization when initializing WebDataRocks:
Set the localization as a URL to the file
<script setup>
import { Pivot } from "@webdatarocks/vue-webdatarocks";
import "@webdatarocks/webdatarocks/webdatarocks.css";
const report = {
// Your report
};
const globalReport = {
// Replace this file with your own localization file
localization: "https://cdn.webdatarocks.com/loc/es.json"
};
</script>
<template>
<div>
<Pivot
v-bind:report="report"
v-bind:global="globalReport"
toolbar
/>
</div>
</template>
Set the localization as an inline JSON object
<script setup>
import {Pivot} from "@webdatarocks/vue-webdatarocks";
import "@webdatarocks/webdatarocks/webdatarocks.css";
const report = {
// Your report
};
const globalReport = {
// Replace the translation below with your own labels
localization: {
fieldList: {
flatHierarchyBox: "Seleccionar y organizar columnas",
hierarchyBox: "Seleccionar dimensiones",
filterBox: "Filtros del Informe",
// Other labels
}
}
};
</script>
<template>
<div>
<Pivot
v-bind:report="report"
v-bind:global="globalReport"
toolbar
/>
</div>
</template>
Learn more about the Global Object.