diff options
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/templates/list')
3 files changed, 24 insertions, 20 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/list/ListPage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/list/ListPage.tsx index dd983918f..9d289e957 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/list/ListPage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/list/ListPage.tsx @@ -21,7 +21,7 @@ import { h, VNode } from "preact"; import { MerchantBackend } from "../../../../declaration.js"; -import { useTranslator } from "../../../../i18n/index.js"; +import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser"; import { CardTable } from "./Table.js"; export interface Props { @@ -43,7 +43,7 @@ export function ListPage({ }: Props): VNode { const form = { payto_uri: "" }; - const i18n = useTranslator(); + const { i18n } = useTranslationContext(); return ( <section class="section is-main-section"> <CardTable diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/list/Table.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/list/Table.tsx index bc8477039..fd6ea5f6f 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/list/Table.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/list/Table.tsx @@ -19,10 +19,10 @@ * @author Sebastian Javier Marchano (sebasjm) */ +import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser"; import { h, VNode } from "preact"; import { StateUpdater, useState } from "preact/hooks"; import { MerchantBackend } from "../../../../declaration.js"; -import { Translate, useTranslator } from "../../../../i18n/index.js"; type Entity = MerchantBackend.Template.TemplateEntry; @@ -49,7 +49,7 @@ export function CardTable({ }: Props): VNode { const [rowSelection, rowSelectionHandler] = useState<string[]>([]); - const i18n = useTranslator(); + const { i18n } = useTranslationContext(); return ( <div class="card has-table"> @@ -58,10 +58,13 @@ export function CardTable({ <span class="icon"> <i class="mdi mdi-newspaper" /> </span> - <Translate>Templates</Translate> + <i18n.Translate>Templates</i18n.Translate> </p> <div class="card-header-icon" aria-label="more options"> - <span class="has-tooltip-left" data-tooltip={i18n`add new templates`}> + <span + class="has-tooltip-left" + data-tooltip={i18n.str`add new templates`} + > <button class="button is-info" type="button" onClick={onCreate}> <span class="icon is-small"> <i class="mdi mdi-plus mdi-36px" /> @@ -120,27 +123,27 @@ function Table({ hasMoreAfter, hasMoreBefore, }: TableProps): VNode { - const i18n = useTranslator(); + const { i18n } = useTranslationContext(); return ( <div class="table-container"> {onLoadMoreBefore && ( <button class="button is-fullwidth" - data-tooltip={i18n`load more templates before the first one`} + data-tooltip={i18n.str`load more templates before the first one`} disabled={!hasMoreBefore} onClick={onLoadMoreBefore} > - <Translate>load newer templates</Translate> + <i18n.Translate>load newer templates</i18n.Translate> </button> )} <table class="table is-fullwidth is-striped is-hoverable is-fullwidth"> <thead> <tr> <th> - <Translate>ID</Translate> + <i18n.Translate>ID</i18n.Translate> </th> <th> - <Translate>Description</Translate> + <i18n.Translate>Description</i18n.Translate> </th> <th /> </tr> @@ -164,7 +167,7 @@ function Table({ <td> <button class="button is-danger is-small has-tooltip-left" - data-tooltip={i18n`delete selected templates from the database`} + data-tooltip={i18n.str`delete selected templates from the database`} onClick={() => onDelete(i)} > Delete @@ -178,11 +181,11 @@ function Table({ {onLoadMoreAfter && ( <button class="button is-fullwidth" - data-tooltip={i18n`load more templates after the last one`} + data-tooltip={i18n.str`load more templates after the last one`} disabled={!hasMoreAfter} onClick={onLoadMoreAfter} > - <Translate>load older templates</Translate> + <i18n.Translate>load older templates</i18n.Translate> </button> )} </div> @@ -190,6 +193,7 @@ function Table({ } function EmptyTable(): VNode { + const { i18n } = useTranslationContext(); return ( <div class="content has-text-grey has-text-centered"> <p> @@ -198,9 +202,9 @@ function EmptyTable(): VNode { </span> </p> <p> - <Translate> + <i18n.Translate> There is no templates yet, add more pressing the + sign - </Translate> + </i18n.Translate> </p> </div> ); diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/list/index.tsx index 0d58093d3..dcac23983 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/list/index.tsx @@ -19,6 +19,7 @@ * @author Sebastian Javier Marchano (sebasjm) */ +import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser"; import { Fragment, h, VNode } from "preact"; import { useState } from "preact/hooks"; import { Loading } from "../../../../components/exception/loading.js"; @@ -29,7 +30,6 @@ import { useInstanceTemplates, useTemplateAPI, } from "../../../../hooks/templates.js"; -import { useTranslator } from "../../../../i18n/index.js"; import { Notification } from "../../../../utils/types.js"; import { ListPage } from "./ListPage.js"; @@ -49,7 +49,7 @@ export default function ListTemplates({ onNotFound, }: Props): VNode { const [position, setPosition] = useState<string | undefined>(undefined); - const i18n = useTranslator(); + const { i18n } = useTranslationContext(); const [notif, setNotif] = useState<Notification | undefined>(undefined); const { deleteTemplate } = useTemplateAPI(); const result = useInstanceTemplates({ position }, (id) => setPosition(id)); @@ -77,13 +77,13 @@ export default function ListTemplates({ deleteTemplate(e.template_id) .then(() => setNotif({ - message: i18n`template delete successfully`, + message: i18n.str`template delete successfully`, type: "SUCCESS", }), ) .catch((error) => setNotif({ - message: i18n`could not delete the template`, + message: i18n.str`could not delete the template`, type: "ERROR", description: error.message, }), |