Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Add ability to translate links.
James Cole4b2abb6f250b
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.phpindex c027514019..f4c1e319b3 100644--- a/app/Support/Twig/General.php+++ b/app/Support/Twig/General.php@@ -61,6 +61,7 @@ class General extends Twig_Extension$this->steamPositive(),$this->activeRoutePartial(),$this->activeRoutePartialWhat(),+];}diff --git a/app/Support/Twig/Translation.php b/app/Support/Twig/Translation.phpindex a01b616bd6..ef64b3aca7 100644--- a/app/Support/Twig/Translation.php+++ b/app/Support/Twig/Translation.php@@ -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_Extensionreturn $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}*/diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex 54d8cebe46..30f0528cd9 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -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:diff --git a/resources/views/transactions/show.twig b/resources/views/transactions/show.twigindex 4b19773112..0fe99308d4 100644--- a/resources/views/transactions/show.twig+++ b/resources/views/transactions/show.twig@@ -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) }})