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}
|
||||
*/
|
||||
|
@ -804,36 +804,36 @@ return [
|
||||
'remove_money_from_piggy_title' => 'Remove money from piggy bank ":name"',
|
||||
'add' => 'Add',
|
||||
|
||||
'remove' => 'Remove',
|
||||
'max_amount_add' => 'The maximum amount you can add is',
|
||||
'max_amount_remove' => 'The maximum amount you can remove is',
|
||||
'update_piggy_button' => 'Update piggy bank',
|
||||
'update_piggy_title' => 'Update piggy bank ":name"',
|
||||
'updated_piggy_bank' => 'Updated piggy bank ":name"',
|
||||
'details' => 'Details',
|
||||
'events' => 'Events',
|
||||
'target_amount' => 'Target amount',
|
||||
'start_date' => 'Start date',
|
||||
'target_date' => 'Target date',
|
||||
'no_target_date' => 'No target date',
|
||||
'table' => 'Table',
|
||||
'delete_piggy_bank' => 'Delete piggy bank ":name"',
|
||||
'cannot_add_amount_piggy' => 'Could not add :amount to ":name".',
|
||||
'cannot_remove_from_piggy' => 'Could not remove :amount from ":name".',
|
||||
'deleted_piggy_bank' => 'Deleted piggy bank ":name"',
|
||||
'added_amount_to_piggy' => 'Added :amount to ":name"',
|
||||
'removed_amount_from_piggy' => 'Removed :amount from ":name"',
|
||||
'remove' => 'Remove',
|
||||
'max_amount_add' => 'The maximum amount you can add is',
|
||||
'max_amount_remove' => 'The maximum amount you can remove is',
|
||||
'update_piggy_button' => 'Update piggy bank',
|
||||
'update_piggy_title' => 'Update piggy bank ":name"',
|
||||
'updated_piggy_bank' => 'Updated piggy bank ":name"',
|
||||
'details' => 'Details',
|
||||
'events' => 'Events',
|
||||
'target_amount' => 'Target amount',
|
||||
'start_date' => 'Start date',
|
||||
'target_date' => 'Target date',
|
||||
'no_target_date' => 'No target date',
|
||||
'table' => 'Table',
|
||||
'delete_piggy_bank' => 'Delete piggy bank ":name"',
|
||||
'cannot_add_amount_piggy' => 'Could not add :amount to ":name".',
|
||||
'cannot_remove_from_piggy' => 'Could not remove :amount from ":name".',
|
||||
'deleted_piggy_bank' => 'Deleted piggy bank ":name"',
|
||||
'added_amount_to_piggy' => 'Added :amount to ":name"',
|
||||
'removed_amount_from_piggy' => 'Removed :amount from ":name"',
|
||||
|
||||
// tags
|
||||
'regular_tag' => 'Just a regular tag.',
|
||||
'balancing_act' => 'The tag takes at most two transactions; an expense and a transfer. They\'ll balance each other out.',
|
||||
'advance_payment' => 'The tag accepts one expense and any number of deposits aimed to repay the original expense.',
|
||||
'delete_tag' => 'Delete tag ":tag"',
|
||||
'deleted_tag' => 'Deleted tag ":tag"',
|
||||
'new_tag' => 'Make new tag',
|
||||
'edit_tag' => 'Edit tag ":tag"',
|
||||
'updated_tag' => 'Updated tag ":tag"',
|
||||
'created_tag' => 'Tag ":tag" has been created!',
|
||||
'regular_tag' => 'Just a regular tag.',
|
||||
'balancing_act' => 'The tag takes at most two transactions; an expense and a transfer. They\'ll balance each other out.',
|
||||
'advance_payment' => 'The tag accepts one expense and any number of deposits aimed to repay the original expense.',
|
||||
'delete_tag' => 'Delete tag ":tag"',
|
||||
'deleted_tag' => 'Deleted tag ":tag"',
|
||||
'new_tag' => 'Make new tag',
|
||||
'edit_tag' => 'Edit tag ":tag"',
|
||||
'updated_tag' => 'Updated tag ":tag"',
|
||||
'created_tag' => 'Tag ":tag" has been created!',
|
||||
|
||||
'transaction_journal_information' => 'Transaction information',
|
||||
'transaction_journal_meta' => 'Meta information',
|
||||
@ -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