mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Add ability to translate links.
This commit is contained in:
parent
72b7900ce2
commit
4b2abb6f25
@ -61,6 +61,7 @@ class General extends Twig_Extension
|
||||
$this->steamPositive(),
|
||||
$this->activeRoutePartial(),
|
||||
$this->activeRoutePartialWhat(),
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ namespace FireflyIII\Support\Twig;
|
||||
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFilter;
|
||||
use Twig_SimpleFunction;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -43,6 +44,39 @@ class Translation extends Twig_Extension
|
||||
return $filters;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getFunctions(): array
|
||||
{
|
||||
return [
|
||||
$this->journalLinkTranslation(),
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
public function journalLinkTranslation(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'journalLinkTranslation', function (int $linkTypeId, string $direction, string $original) {
|
||||
$key = sprintf('firefly.%d_%s', $linkTypeId, $direction);
|
||||
$translation = trans($key);
|
||||
if($key === $translation) {
|
||||
return $original;
|
||||
}
|
||||
|
||||
return $translation;
|
||||
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -899,6 +899,14 @@ return [
|
||||
'overview_for_link' => 'Overview for link type ":name"',
|
||||
'delete_journal_link' => 'Delete the link between <a href=":source_link">:source</a> and <a href=":destination_link">:destination</a>',
|
||||
'deleted_link' => 'Deleted link',
|
||||
'1_outward' => 'relates to',
|
||||
'2_outward' => '(partially) refunds',
|
||||
'3_outward' => '(partially) pays for',
|
||||
'4_outward' => '(partially) reimburses',
|
||||
'1_inward' => 'relates to',
|
||||
'2_inward' => 'is (partially) refunded by',
|
||||
'3_inward' => 'is (partially) paid for by',
|
||||
'4_inward' => 'is (partially) reimbursed by',
|
||||
|
||||
|
||||
// split a transaction:
|
||||
|
@ -329,13 +329,13 @@
|
||||
<td>
|
||||
{{ ('this_'~(what|lower))|_ }}
|
||||
{% if link.source.id == journal.id %}
|
||||
{{ link.linkType.outward }}
|
||||
{{ journalLinkTranslation(link.link_type_id,'outward', link.linkType.outward) }}
|
||||
<a href="{{ route('transactions.show',link.destination.id) }}">
|
||||
#{{ link.destination.id }}: {{ link.destination.description }}
|
||||
</a>
|
||||
({{ journalAmount(link.destination) }})
|
||||
{% else %}
|
||||
{{ link.linkType.inward }}
|
||||
{{ journalLinkTranslation(link.link_type_id,'inward', link.linkType.inward) }}
|
||||
<a href="{{ route('transactions.show',link.source.id) }}">
|
||||
#{{ link.source.id }}: {{ link.source.description }}</a>
|
||||
({{ journalAmount(link.source) }})
|
||||
|
Loading…
Reference in New Issue
Block a user