AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

StorefrontText.php 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. 'not_enough_stock' => 'Some items in your cart share the same stock, and there is not enough for all of them. Please lower a quantity.',
  14. 'sold_out' => 'This product is sold out.',
  15. 'choose_option' => 'Please choose an option first.',
  16. 'payment_unavailable' => 'We could not start the payment. Please try again in a moment.',
  17. 'not_taking_orders' => 'This store is not taking orders yet. Please check back soon.',
  18. 'discount_invalid' => 'This code is not valid.',
  19. 'discount_not_started' => 'This code cannot be used yet.',
  20. 'discount_expired' => 'This code has expired.',
  21. 'discount_used_up' => 'This code has been used up.',
  22. 'discount_minimum' => 'Spend at least :amount on products to use this code.',
  23. 'discount_total_too_low' => 'After the discount, the order total must be at least RM 2.00.',
  24. 'discount_changed' => 'Your discount code can no longer be used, so it was removed. Please check your total.',
  25. 'discount_offer_better' => ':name already saves you more, so this code is not used. Only one discount applies per order.',
  26. 'offer_add_items' => 'Add :count more to get :label (:name).',
  27. 'offer_spend_more' => 'Spend :amount more to get :label (:name).',
  28. 'announce_free_shipping' => 'Free shipping on orders over :amount',
  29. 'announce_free_shipping_all' => 'Free shipping on every order',
  30. ],
  31. 'ms' => [
  32. 'cart_empty' => 'Troli anda kosong.',
  33. 'minimum_total' => 'Jumlah pesanan mestilah sekurang-kurangnya RM 2.00.',
  34. 'not_enough_stock' => 'Beberapa barang dalam troli anda berkongsi stok yang sama, dan stok tidak mencukupi untuk semuanya. Sila kurangkan kuantiti.',
  35. 'sold_out' => 'Produk ini telah habis dijual.',
  36. 'choose_option' => 'Sila pilih satu pilihan dahulu.',
  37. 'payment_unavailable' => 'Kami tidak dapat memulakan pembayaran. Sila cuba sebentar lagi.',
  38. 'not_taking_orders' => 'Kedai ini belum menerima pesanan. Sila datang semula nanti.',
  39. 'discount_invalid' => 'Kod ini tidak sah.',
  40. 'discount_not_started' => 'Kod ini belum boleh digunakan.',
  41. 'discount_expired' => 'Kod ini telah tamat tempoh.',
  42. 'discount_used_up' => 'Kod ini telah habis digunakan.',
  43. 'discount_minimum' => 'Belanja sekurang-kurangnya :amount untuk produk bagi menggunakan kod ini.',
  44. 'discount_total_too_low' => 'Selepas diskaun, jumlah pesanan mestilah sekurang-kurangnya RM 2.00.',
  45. 'discount_changed' => 'Kod diskaun anda tidak lagi boleh digunakan, jadi ia telah dibuang. Sila semak jumlah anda.',
  46. 'discount_offer_better' => ':name sudah memberi anda jimat lebih, jadi kod ini tidak digunakan. Hanya satu diskaun bagi setiap pesanan.',
  47. 'offer_add_items' => 'Tambah :count lagi untuk dapat :label (:name).',
  48. 'offer_spend_more' => 'Belanja :amount lagi untuk dapat :label (:name).',
  49. 'announce_free_shipping' => 'Penghantaran percuma untuk pesanan melebihi :amount',
  50. 'announce_free_shipping_all' => 'Penghantaran percuma untuk semua pesanan',
  51. ],
  52. ];
  53. /**
  54. * @param array<string, string> $replace Words to put in, such as [':amount' => 'RM 50.00'].
  55. */
  56. public static function line(string $language, string $key, array $replace = []): string
  57. {
  58. return strtr(self::LINES[$language][$key] ?? self::LINES['en'][$key], $replace);
  59. }
  60. /**
  61. * Messages for the checkout form's checks.
  62. *
  63. * @return array<string, string>
  64. */
  65. public static function checkoutMessages(string $language): array
  66. {
  67. if ($language === 'ms') {
  68. return [
  69. 'required' => ':attribute diperlukan.',
  70. 'string' => ':attribute tidak sah.',
  71. 'email' => ':attribute mestilah alamat e-mel yang sah.',
  72. 'min' => ':attribute mestilah sekurang-kurangnya :min aksara.',
  73. 'max' => ':attribute tidak boleh melebihi :max aksara.',
  74. 'phone.regex' => 'Sila masukkan nombor telefon yang sah.',
  75. 'postcode.regex' => 'Poskod mestilah 5 digit.',
  76. 'state.in' => 'Sila pilih negeri.',
  77. ];
  78. }
  79. return [
  80. 'phone.regex' => 'Please enter a valid phone number.',
  81. 'postcode.regex' => 'The postcode must be 5 digits.',
  82. 'state.in' => 'Please choose a state.',
  83. ];
  84. }
  85. /**
  86. * How the checkout fields are named inside those messages.
  87. *
  88. * @return array<string, string>
  89. */
  90. public static function checkoutFields(string $language): array
  91. {
  92. return $language === 'ms'
  93. ? ['name' => 'Nama penuh', 'email' => 'E-mel', 'phone' => 'Nombor telefon', 'line1' => 'Alamat', 'line2' => 'Alamat baris 2', 'city' => 'Bandar', 'postcode' => 'Poskod', 'state' => 'Negeri']
  94. : ['name' => 'full name', 'email' => 'email', 'phone' => 'phone number', 'line1' => 'address', 'line2' => 'address line 2', 'city' => 'city', 'postcode' => 'postcode', 'state' => 'state'];
  95. }
  96. }