AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

StorefrontText.php 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Storefront;
  3. /**
  4. * Messages the server shows to shoppers, in the store's language.
  5. * The words drawn by the browser live in resources/js/storefront/text.ts.
  6. */
  7. final class StorefrontText
  8. {
  9. private const array LINES = [
  10. 'en' => [
  11. 'cart_empty' => 'Your cart is empty.',
  12. 'minimum_total' => 'The order total must be at least RM 2.00.',
  13. 'sold_out' => 'This product is sold out.',
  14. 'payment_unavailable' => 'We could not start the payment. Please try again in a moment.',
  15. ],
  16. 'ms' => [
  17. 'cart_empty' => 'Troli anda kosong.',
  18. 'minimum_total' => 'Jumlah pesanan mestilah sekurang-kurangnya RM 2.00.',
  19. 'sold_out' => 'Produk ini telah habis dijual.',
  20. 'payment_unavailable' => 'Kami tidak dapat memulakan pembayaran. Sila cuba sebentar lagi.',
  21. ],
  22. ];
  23. public static function line(string $language, string $key): string
  24. {
  25. return self::LINES[$language][$key] ?? self::LINES['en'][$key];
  26. }
  27. /**
  28. * Messages for the checkout form's checks.
  29. *
  30. * @return array<string, string>
  31. */
  32. public static function checkoutMessages(string $language): array
  33. {
  34. if ($language === 'ms') {
  35. return [
  36. 'required' => ':attribute diperlukan.',
  37. 'string' => ':attribute tidak sah.',
  38. 'email' => ':attribute mestilah alamat e-mel yang sah.',
  39. 'min' => ':attribute mestilah sekurang-kurangnya :min aksara.',
  40. 'max' => ':attribute tidak boleh melebihi :max aksara.',
  41. 'phone.regex' => 'Sila masukkan nombor telefon yang sah.',
  42. 'postcode.regex' => 'Poskod mestilah 5 digit.',
  43. 'state.in' => 'Sila pilih negeri.',
  44. ];
  45. }
  46. return [
  47. 'phone.regex' => 'Please enter a valid phone number.',
  48. 'postcode.regex' => 'The postcode must be 5 digits.',
  49. 'state.in' => 'Please choose a state.',
  50. ];
  51. }
  52. /**
  53. * How the checkout fields are named inside those messages.
  54. *
  55. * @return array<string, string>
  56. */
  57. public static function checkoutFields(string $language): array
  58. {
  59. return $language === 'ms'
  60. ? ['name' => 'Nama penuh', 'email' => 'E-mel', 'phone' => 'Nombor telefon', 'line1' => 'Alamat', 'line2' => 'Alamat baris 2', 'city' => 'Bandar', 'postcode' => 'Poskod', 'state' => 'Negeri']
  61. : ['name' => 'full name', 'email' => 'email', 'phone' => 'phone number', 'line1' => 'address', 'line2' => 'address line 2', 'city' => 'city', 'postcode' => 'postcode', 'state' => 'state'];
  62. }
  63. }