Skip to content

Implementing localization

Roberto Prevato edited this page Apr 30, 2017 · 4 revisions

KingTable library keeps localized strings inside a property called regional:

  KingTable.regional;

By default, en regional is included in the distributed KingTable library. Following instructions show how to implement localization for the KingTable library. For the sake of example, Italian localization is used.

1. Extend the KingTable.regional object

  // example of client side localization (the same key added to regional object is used by `lang` option)
  KingTable.regional.it = {
    "goToDetails": "Dettagli",
    "sortOptions": "Ordinamento",
    "searchSortingRules": "Durante una ricerca testuale, ordina per rilevanza.",
    "advancedFilters": "Filtri avanzati",
    "sortModes": {
      "simple": "Semplice (proprietà singola)",
      "complex": "Complesso (proprietà multiple)"
    },
    "viewsType": {
      "table": "Tabella",
      "gallery": "Galleria"
    },
    "exportFormats": {
      "csv": "Csv",
      "json": "Json",
      "xml": "Xml"
    },
    "columns": "Colonne",
    "export": "Esporta",
    "view": "Vista",
    "views": "Viste",
    "loading": "Caricamento dati",
    "noData": "Nessun oggetto da mostrare",
    "page": "Pagina",
    "resultsPerPage": "Risultati per pagina",
    "results": "Risultati",
    "of": "di",
    "firstPage": "Prima pagina",
    "lastPage": "Ultima pagina",
    "prevPage": "Pagina precedente",
    "nextPage": "Prossima pagina",
    "refresh": "Ricarica",
    "fetchTime": "Dati caricati alle:",
    "anchorTime": "Dati fino alle:",
    "sortAscendingBy": "Ordina per  crescente",
    "sortDescendingBy": "Ordina per  decrescente",
    "errorFetchingData": "Si è verificato un errore durante il caricamento dei dati."
  };

2. Configure KingTable for all instances, or for a single instance

  // for all instances:
  KingTable.defaults.lang = "it";

  // for single instance, use 'lang' option in table constructor
  // lang must be defined inside the KingTable.regional object, otherwise an exception is thrown