1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Utils/TranslationHelper.php

74 lines
2.1 KiB
PHP
Raw Normal View History

<?php
2019-05-11 05:32:07 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
2019-05-11 05:32:07 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-28 23:21:40 +01:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
2019-05-11 05:32:07 +02:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2019-05-11 05:32:07 +02:00
*/
namespace App\Utils;
use App\Models\PaymentTerm;
2023-08-10 01:39:59 +02:00
use \Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
class TranslationHelper
{
public static function getIndustries()
{
return Cache::get('industries')->each(function ($industry) {
$industry->name = ctrans('texts.industry_'.$industry->name);
})->sortBy(function ($industry) {
return $industry->name;
});
}
public static function getCountries()
{
return Cache::get('countries')->each(function ($country) {
$country->name = ctrans('texts.country_'.$country->name);
})->sortBy(function ($country) {
return $country->iso_3166_2;
});
}
public static function getPaymentTypes()
{
return Cache::get('payment_types')->each(function ($pType) {
$pType->name = ctrans('texts.payment_type_'.$pType->name);
})->sortBy(function ($pType) {
return $pType->name;
});
}
public static function getLanguages()
{
return Cache::get('languages')->each(function ($lang) {
$lang->name = ctrans('texts.lang_'.$lang->name);
})->sortBy(function ($lang) {
return $lang->name;
});
}
public static function getCurrencies()
{
return Cache::get('currencies')->each(function ($currency) {
$currency->name = ctrans('texts.currency_'.Str::slug($currency->name, '_'));
})->sortBy(function ($currency) {
return $currency->name;
});
}
public static function getPaymentTerms()
{
return PaymentTerm::getCompanyTerms()->map(function ($term) {
$term['name'] = ctrans('texts.payment_terms_net').' '.$term['num_days'];
return $term;
});
}
}