| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
-
- namespace App\Storefront;
-
- /**
- * Messages the server shows to shoppers, in the store's language.
- * The words drawn by the browser live in resources/js/storefront/text.ts.
- */
- final class StorefrontText
- {
- private const array LINES = [
- 'en' => [
- 'cart_empty' => 'Your cart is empty.',
- 'minimum_total' => 'The order total must be at least RM 2.00.',
- 'sold_out' => 'This product is sold out.',
- 'payment_unavailable' => 'We could not start the payment. Please try again in a moment.',
- 'discount_invalid' => 'This code is not valid.',
- 'discount_not_started' => 'This code cannot be used yet.',
- 'discount_expired' => 'This code has expired.',
- 'discount_used_up' => 'This code has been used up.',
- 'discount_minimum' => 'Spend at least :amount on products to use this code.',
- 'discount_total_too_low' => 'After the discount, the order total must be at least RM 2.00.',
- 'discount_changed' => 'Your discount code can no longer be used, so it was removed. Please check your total.',
- ],
- 'ms' => [
- 'cart_empty' => 'Troli anda kosong.',
- 'minimum_total' => 'Jumlah pesanan mestilah sekurang-kurangnya RM 2.00.',
- 'sold_out' => 'Produk ini telah habis dijual.',
- 'payment_unavailable' => 'Kami tidak dapat memulakan pembayaran. Sila cuba sebentar lagi.',
- 'discount_invalid' => 'Kod ini tidak sah.',
- 'discount_not_started' => 'Kod ini belum boleh digunakan.',
- 'discount_expired' => 'Kod ini telah tamat tempoh.',
- 'discount_used_up' => 'Kod ini telah habis digunakan.',
- 'discount_minimum' => 'Belanja sekurang-kurangnya :amount untuk produk bagi menggunakan kod ini.',
- 'discount_total_too_low' => 'Selepas diskaun, jumlah pesanan mestilah sekurang-kurangnya RM 2.00.',
- 'discount_changed' => 'Kod diskaun anda tidak lagi boleh digunakan, jadi ia telah dibuang. Sila semak jumlah anda.',
- ],
- ];
-
- /**
- * @param array<string, string> $replace Words to put in, such as [':amount' => 'RM 50.00'].
- */
- public static function line(string $language, string $key, array $replace = []): string
- {
- return strtr(self::LINES[$language][$key] ?? self::LINES['en'][$key], $replace);
- }
-
- /**
- * Messages for the checkout form's checks.
- *
- * @return array<string, string>
- */
- public static function checkoutMessages(string $language): array
- {
- if ($language === 'ms') {
- return [
- 'required' => ':attribute diperlukan.',
- 'string' => ':attribute tidak sah.',
- 'email' => ':attribute mestilah alamat e-mel yang sah.',
- 'min' => ':attribute mestilah sekurang-kurangnya :min aksara.',
- 'max' => ':attribute tidak boleh melebihi :max aksara.',
- 'phone.regex' => 'Sila masukkan nombor telefon yang sah.',
- 'postcode.regex' => 'Poskod mestilah 5 digit.',
- 'state.in' => 'Sila pilih negeri.',
- ];
- }
-
- return [
- 'phone.regex' => 'Please enter a valid phone number.',
- 'postcode.regex' => 'The postcode must be 5 digits.',
- 'state.in' => 'Please choose a state.',
- ];
- }
-
- /**
- * How the checkout fields are named inside those messages.
- *
- * @return array<string, string>
- */
- public static function checkoutFields(string $language): array
- {
- return $language === 'ms'
- ? ['name' => 'Nama penuh', 'email' => 'E-mel', 'phone' => 'Nombor telefon', 'line1' => 'Alamat', 'line2' => 'Alamat baris 2', 'city' => 'Bandar', 'postcode' => 'Poskod', 'state' => 'Negeri']
- : ['name' => 'full name', 'email' => 'email', 'phone' => 'phone number', 'line1' => 'address', 'line2' => 'address line 2', 'city' => 'city', 'postcode' => 'postcode', 'state' => 'state'];
- }
- }
|