From dcdf1ea83c270d89ce1f9a144bfed514b61af228 Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Thu, 26 Jan 2023 15:40:03 -0800 Subject: [PATCH] Make module's settings labels translatable --- src/modules/Client/Service.php | 8 ++++---- src/modules/Cron/Service.php | 2 +- src/modules/Email/Service.php | 2 +- src/modules/Example/Service.php | 4 ++-- src/modules/Invoice/Service.php | 8 ++++---- src/modules/Order/Service.php | 8 ++++---- src/modules/Support/Service.php | 8 ++++---- src/modules/System/Service.php | 31 ++++++++++++++++--------------- 8 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/modules/Client/Service.php b/src/modules/Client/Service.php index de7e22af9..793aa418f 100644 --- a/src/modules/Client/Service.php +++ b/src/modules/Client/Service.php @@ -43,19 +43,19 @@ class Service implements InjectionAwareInterface return array( 'active' => array( 'path' => '/client?status=active', - 'label' => 'Active clients', + 'label' => __trans('Active clients'), ), 'suspended' => array( 'path' => '/client?status=suspended', - 'label' => 'Suspended clients', + 'label' => __trans('Suspended clients'), ), 'canceled' => array( 'path' => '/client?status=canceled', - 'label' => 'Canceled clients', + 'label' => __trans('Canceled clients'), ), 'all' => array( 'path' => '/client', - 'label' => 'All clients', + 'label' => __trans('All clients'), ), ); } diff --git a/src/modules/Cron/Service.php b/src/modules/Cron/Service.php index cdc51718d..1bfc600e2 100644 --- a/src/modules/Cron/Service.php +++ b/src/modules/Cron/Service.php @@ -35,7 +35,7 @@ class Service return array( 'exec' => array( 'path' => BB_URL . 'cron.php', - 'label' => 'Execute now', + 'label' => __trans('Execute now'), ), ); } diff --git a/src/modules/Email/Service.php b/src/modules/Email/Service.php index c774bcb1a..7a9cbf537 100644 --- a/src/modules/Email/Service.php +++ b/src/modules/Email/Service.php @@ -35,7 +35,7 @@ class Service implements \Box\InjectionAwareInterface return [ 'history' => [ 'path' => 'email/history', - 'label' => 'Email history', + 'label' => __trans('Email history'), ], ]; } diff --git a/src/modules/Example/Service.php b/src/modules/Example/Service.php index ebf7e72a2..943076bdf 100644 --- a/src/modules/Example/Service.php +++ b/src/modules/Example/Service.php @@ -42,11 +42,11 @@ class Service return array( 'source' => array( 'path' => 'https://github.com/FOSSBilling/example', // An example external link - 'label' => 'View source code', + 'label' => __trans('View source code'), ), 'example' => array( 'path' => 'extension/settings/example', // An example internal link. Internal links are relative to the custom admin panel path. - 'label' => 'This is an example!', + 'label' => __trans('This is an example!'), ), ); } diff --git a/src/modules/Invoice/Service.php b/src/modules/Invoice/Service.php index cba8b98f6..042280731 100644 --- a/src/modules/Invoice/Service.php +++ b/src/modules/Invoice/Service.php @@ -47,19 +47,19 @@ class Service implements InjectionAwareInterface return array( 'unpaid' => array( 'path' => '/invoice?status=unpaid', - 'label' => 'Unpaid invoices', + 'label' => __trans('Unpaid invoices'), ), 'paid' => array( 'path' => '/invoice?status=paid', - 'label' => 'Paid invoices', + 'label' => __trans('Paid invoices'), ), 'refunded' => array( 'path' => '/invoice?status=refunded', - 'label' => 'Refunded invoices', + 'label' => __trans('Refunded invoices'), ), 'all' => array( 'path' => '/invoice', - 'label' => 'All invoices', + 'label' => __trans('All invoices'), ), ); } diff --git a/src/modules/Order/Service.php b/src/modules/Order/Service.php index 098589745..93355dea7 100644 --- a/src/modules/Order/Service.php +++ b/src/modules/Order/Service.php @@ -43,19 +43,19 @@ class Service implements InjectionAwareInterface return array( 'pending_setup' => array( 'path' => '/order?status=pending_setup', - 'label' => 'Orders pending setup', + 'label' => __trans('Orders pending setup'), ), 'active' => array( 'path' => '/order?status=active', - 'label' => 'Active orders', + 'label' => __trans('Active orders'), ), 'suspended' => array( 'path' => '/order?status=suspended', - 'label' => 'Suspended orders', + 'label' => __trans('Suspended orders'), ), 'all' => array( 'path' => '/order', - 'label' => 'All orders', + 'label' => __trans('All orders'), ), ); } diff --git a/src/modules/Support/Service.php b/src/modules/Support/Service.php index 6c93d576b..00506ef1d 100644 --- a/src/modules/Support/Service.php +++ b/src/modules/Support/Service.php @@ -35,19 +35,19 @@ class Service implements \Box\InjectionAwareInterface return array( 'open' => array( 'path' => '/support?status=open', - 'label' => 'Tickets waiting for staff reply', + 'label' => __trans('Tickets waiting for staff reply'), ), 'on_hold' => array( 'path' => '/support?status=on_hold', - 'label' => 'Tickets waiting for client reply', + 'label' => __trans('Tickets waiting for client reply'), ), 'closed' => array( 'path' => '/support?status=closed', - 'label' => 'Resolved tickets', + 'label' => __trans('Resolved tickets'), ), 'all' => array( 'path' => '/support', - 'label' => 'All tickets', + 'label' => __trans('All tickets'), ), ); } diff --git a/src/modules/System/Service.php b/src/modules/System/Service.php index 8d90852f8..ee0748373 100644 --- a/src/modules/System/Service.php +++ b/src/modules/System/Service.php @@ -30,15 +30,15 @@ class Service return array( 'report_bug' => array( 'path' => 'https://github.com/FOSSBilling/FOSSBilling/issues/', - 'label' => 'Report a bug', + 'label' => __trans('Report a bug'), ), 'activity' => array( 'path' => 'activity', - 'label' => 'Event history', + 'label' => __trans('Event history'), ), 'languages' => array( 'path' => 'extension/languages', - 'label' => 'Languages', + 'label' => __trans('Languages'), ), ); } @@ -206,25 +206,25 @@ class Service closedir($handle); } sort($locales); - if(!$deep){ + if (!$deep) { return $locales; } $array = include PATH_ROOT . '/locale/locales.php'; $details = []; - foreach($locales as $locale){ - if (empty($array[$locale])){ + foreach ($locales as $locale) { + if (empty($array[$locale])) { //fall back on locale string $details[] = [ 'locale' => $locale, - 'title' => $locale .' ('.$locale.')', + 'title' => $locale . ' (' . $locale . ')', 'name' => $locale, ]; - }else{ - $details[] = [ - 'locale' => $locale, - 'title' => $array[$locale] .' ('.$locale.')', - 'name' => $array[$locale], - ]; + } else { + $details[] = [ + 'locale' => $locale, + 'title' => $array[$locale] . ' (' . $locale . ')', + 'name' => $array[$locale], + ]; } } return $details; @@ -345,7 +345,7 @@ class Service // skip if admin is not logged in } } - if(is_null($tpl)){ + if (is_null($tpl)) { $parsed = $this->createTemplateFromString("No template was provided, please contact the site administrator", $try_render, $vars); return $parsed; } @@ -992,7 +992,8 @@ class Service $list = [ 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', - 'PL', 'PT', 'RO', 'SE', 'SI', 'SK', ]; + 'PL', 'PT', 'RO', 'SE', 'SI', 'SK', + ]; $c = $this->getCountries(); $res = []; foreach ($list as $code) {