i18n compatible datatable

This commit is contained in:
Philipp Dormann 2020-12-29 21:32:06 +01:00
parent 016f08b07c
commit 3c36bea07c
4 changed files with 79 additions and 35 deletions

View File

@ -1,11 +1,13 @@
<script> <script>
import { _, t } from "svelte-i18n";
import { getlang } from "./datatable_i18n";
import { Grid } from "gridjs"; import { Grid } from "gridjs";
import "gridjs/dist/theme/mermaid.css"; import "gridjs/dist/theme/mermaid.css";
import { nanoid } from "nanoid";
// //
const uniq = nanoid(); let table;
const datatable = new Grid({ const datatable = new Grid({
columns: ["Name", "Email", "Phone Number"], columns: ["Name", "Email", "Phone Number"],
language: getlang($_("datatable")),
sort: true, sort: true,
search: { enabled: true }, search: { enabled: true },
data: [ data: [
@ -22,8 +24,8 @@
}, },
}); });
setTimeout(() => { setTimeout(() => {
datatable.render(document.getElementById("wrapper" + uniq)); datatable.render(table);
}, 0); }, 0);
</script> </script>
<div id="wrapper{uniq}" /> <div bind:this={table} />

View File

@ -0,0 +1,24 @@
export function getlang(langkeys) {
return {
search: {
placeholder: langkeys.search
},
sort: {
sortAsc: langkeys.sort_column_ascending,
sortDesc: langkeys.sort_column_descending
},
pagination: {
previous: langkeys.previous,
next: langkeys.next,
navigate: (page, pages) => `${langkeys.page} ${page} ${langkeys.of} ${pages}`,
page: (page) => `${langkeys.page} ${page}`,
showing: langkeys.showing,
of: langkeys.of,
to: langkeys.to,
results: langkeys.records
},
loading: langkeys.loading,
noRecordsFound: langkeys.no_matching_records_found,
error: langkeys.an_error_happened_while_fetching_the_data
};
}

View File

@ -21,5 +21,8 @@
"dont-have-your-email-connected": "Deine E-Mail ist nicht verknüpft?", "dont-have-your-email-connected": "Deine E-Mail ist nicht verknüpft?",
"reset-my-password": "Passwort zurücksetzen", "reset-my-password": "Passwort zurücksetzen",
"e-mail-adress": "E-Mail-Adresse", "e-mail-adress": "E-Mail-Adresse",
"invalid-mail-reset": "Das ist keine gültige E-Mail" "invalid-mail-reset": "Das ist keine gültige E-Mail",
"datatable": {
"search": "🔍 Suche ..."
}
} }

View File

@ -1,32 +1,47 @@
{ {
"forgot_password?": "Forgot your password?", "forgot_password?": "Forgot your password?",
"register": "Register", "register": "Register",
"log_in": "Log in", "log_in": "Log in",
"password": "Password", "password": "Password",
"log_in_to_your_account": "Log in to your account", "log_in_to_your_account": "Log in to your account",
"welcome_wavinghand": "Welcome 👋", "welcome_wavinghand": "Welcome 👋",
"login_is_checked": "Login is being checked...", "login_is_checked": "Login is being checked...",
"error_on_login": "Error on login", "error_on_login": "Error on login",
"settings": "Settings", "settings": "Settings",
"your_profile": "Your Profile", "your_profile": "Your Profile",
"email_address_or_username": "Email / username", "email_address_or_username": "Email / username",
"tracks": "Tracks", "tracks": "Tracks",
"signout": "Sign out", "signout": "Sign out",
"hallo": "hallo", "hallo": "hallo",
"404message": "Sorry, the page you are looking for could not be found.", "404message": "Sorry, the page you are looking for could not be found.",
"404title": "Error 404", "404title": "Error 404",
"goback": "Go Home", "goback": "Go Home",
"application_name": "Lauf für Kaya! - Admin", "application_name": "Lauf für Kaya! - Admin",
"reset-my-password": "Reset my password", "reset-my-password": "Reset my password",
"cannot-reset-your-password-directly": "Bummer. We unfortunately cannot reset your password directly. Please send us a mail and confirm your identity", "cannot-reset-your-password-directly": "Bummer. We unfortunately cannot reset your password directly. Please send us a mail and confirm your identity",
"send-a-mail-to-lfk-odit-services": "send a mail to lfk@odit.services", "send-a-mail-to-lfk-odit-services": "send a mail to lfk@odit.services",
"dont-have-your-email-connected": "Don't have your email connected?", "dont-have-your-email-connected": "Don't have your email connected?",
"dont-panic-were-resetting-it": "Don't panic, we're resetting it ✌", "dont-panic-were-resetting-it": "Don't panic, we're resetting it ✌",
"e-mail-adress": "E-Mail Adress", "e-mail-adress": "E-Mail Adress",
"mail-validation-in-progress": "mail validation in progress...", "mail-validation-in-progress": "mail validation in progress...",
"invalid-mail-reset": "the provided email is invalid", "invalid-mail-reset": "the provided email is invalid",
"runners": "runners", "runners": "runners",
"total-scans": "total scans", "total-scans": "total scans",
"total-donations": "total donations", "total-donations": "total donations",
"total-distance": "total distance" "total-distance": "total distance",
"datatable": {
"search": "🔍 Search...",
"sort_column_ascending": "Sort column ascending",
"sort_column_descending": "Sort column descending",
"previous": "Previous",
"next": "Next",
"page": "Page",
"showing": "Showing",
"records": "Records",
"of": "of",
"to": "to",
"loading": "Loading...",
"no_matching_records_found": "No matching records found",
"an_error_happened_while_fetching_the_data": "An error happened while fetching the data"
}
} }