Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tms1987's avatar

Translating database entries OR: Concepts for a payment history

Hello,

I am looking for a way on how I can create a booking history for my users. Assuming, I have a PaymentHistory-MySQL-Table, consisting of id, user_id, timestamp, description and price.

As my website is available in multiple languages, I am looking for a way to fill the description column in a "good" way. Let's go into some example descriptions (English <--> German):

Payment domain www.example.com <--> Zahlung Domain www.example.com Payment domain www.example_two.com <--> Zahlung Domain www.example_two.com Refund 202100001 <--> Erstattung 202100001 Refund 202100002 <--> Erstattung 202100002 16 % taxes <--> 16% Steuern

So in general, there are some language-dependent parts as well as some user- or article-dependent parts within the description I want to display. If it would be plain text, I would use something like

__('messages.payment_domain', ['domain' => 'www.example.com']);
__('messages.refund', ['refund_nr' => '202100001']);

Now, I am wondering, what would be the best way to store this information in the database?

My best idea until now, is to add an addition row to the database, e.g. description_type=1 for Payments, description_type=2 for Refunds and so on and then do a case switch within my blade-file:

@switch($i)
    @case(1)
        {{__('messages.payment_domain', ['domain' => $description]);}}
        @break

    @case(2)
       __('messages.refund', ['refund_nr' => $description]);
        @break
@endswitch

This however would result in a separation of information between database (where the user- or article-depending parts are stored) and blade-files (where the language-specific parts are stored).

Is there are more general way on how I can store all information within the database?

0 likes
0 replies

Please or to participate in this conversation.