Update
This commit is contained in:
96
public/admin/js/datatables-locale.js
Normal file
96
public/admin/js/datatables-locale.js
Normal file
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* DataTables Locale Configuration
|
||||
* Provides locale-specific strings for DataTables based on Laravel's app()->getLocale()
|
||||
*/
|
||||
window.DataTablesLocale = (function() {
|
||||
'use strict';
|
||||
|
||||
// Get the current locale from Laravel
|
||||
const locale = document.documentElement.lang || 'en';
|
||||
|
||||
// Define locale configurations
|
||||
const locales = {
|
||||
'sl': {
|
||||
processing: "Obdelava...",
|
||||
search: "Išči:",
|
||||
lengthMenu: "Prikaži _MENU_ vnosov na stran",
|
||||
info: "Prikazujem _START_ do _END_ od _TOTAL_ vnosov",
|
||||
infoEmpty: "Prikazujem 0 do 0 od 0 vnosov",
|
||||
infoFiltered: "(filtrirano od _MAX_ vnosov)",
|
||||
infoPostFix: "",
|
||||
loadingRecords: "Nalagam...",
|
||||
zeroRecords: "Ni najdenih zapisov",
|
||||
emptyTable: "V tabeli ni podatkov",
|
||||
paginate: {
|
||||
first: "Prva",
|
||||
previous: "Prejšnja",
|
||||
next: "Naslednja",
|
||||
last: "Zadnja"
|
||||
},
|
||||
aria: {
|
||||
sortAscending: ": aktiviraj za naraščajoče razvrščanje",
|
||||
sortDescending: ": aktiviraj za padajoče razvrščanje"
|
||||
}
|
||||
},
|
||||
'en': {
|
||||
processing: "Processing...",
|
||||
search: "Search:",
|
||||
lengthMenu: "Show _MENU_ entries",
|
||||
info: "Showing _START_ to _END_ of _TOTAL_ entries",
|
||||
infoEmpty: "Showing 0 to 0 of 0 entries",
|
||||
infoFiltered: "(filtered from _MAX_ total entries)",
|
||||
infoPostFix: "",
|
||||
loadingRecords: "Loading...",
|
||||
zeroRecords: "No matching records found",
|
||||
emptyTable: "No data available in table",
|
||||
paginate: {
|
||||
first: "First",
|
||||
previous: "Previous",
|
||||
next: "Next",
|
||||
last: "Last"
|
||||
},
|
||||
aria: {
|
||||
sortAscending: ": activate to sort column ascending",
|
||||
sortDescending: ": activate to sort column descending"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the locale configuration for the current language
|
||||
* @returns {Object} Locale configuration object
|
||||
*/
|
||||
function getLocaleConfig() {
|
||||
return locales[locale] || locales['en'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize DataTable with automatic locale support
|
||||
* @param {string} selector - jQuery selector for the table
|
||||
* @param {Object} options - DataTable options object
|
||||
* @returns {Object} DataTable instance
|
||||
*/
|
||||
function initDataTable(selector, options = {}) {
|
||||
// Merge locale configuration with provided options
|
||||
const config = Object.assign({}, options, {
|
||||
language: getLocaleConfig()
|
||||
});
|
||||
|
||||
return $(selector).DataTable(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current locale
|
||||
* @returns {string} Current locale code
|
||||
*/
|
||||
function getCurrentLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
// Public API
|
||||
return {
|
||||
getConfig: getLocaleConfig,
|
||||
init: initDataTable,
|
||||
locale: getCurrentLocale
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user