Our pivot table can easily be translated into different languages. This article describes the process of language localization for WebDataRocks reporting component.
Localization files for new languages can be added by creating a new pull request on GitHub. Our team highly appreciates any help.
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).
To set a specific language for a report, add a report.localization
property with the necessary localization:
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"
}
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
}
}
}
If you want to set one language for all reports, add a global
object with localization when initializing WebDataRocks:
let pivot = new WebDataRocks({
container: "#pivot-container",
report: {
// Your report
},
global: {
// Replace this file with own localization file
localization: "https://cdn.webdatarocks.com/loc/es.json"
}
});
let pivot = new WebDataRocks({
container: "#pivot-container",
report: {
// Your report
},
global: {
// Replace the translation below with your own labels
localization: {
fieldsList: {
flatHierarchyBox: "Seleccionar y organizar columnas",
hierarchyBox: "Seleccionar dimensiones",
filterBox: "Filtros del Informe",
// Other labels
}
}
}
});
Learn more about the Global Object.