1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace WC_POS\API;
13
14 use WC_API_Resource;
15 use WC_API_Server;
16
17 class i18n extends WC_API_Resource {
18
19 protected $base = '/pos/i18n';
20
21 22 23 24 25 26 27 28
29 public function register_routes( array $routes ) {
30
31
32 $routes[ $this->base ] = array(
33 array( array( $this, 'get_translations' ), WC_API_Server::READABLE )
34 );
35
36 return $routes;
37
38 }
39
40 41 42
43 public function get_translations(){
44
45 return apply_filters( 'woocommerce_pos_i18n', array(
46 'titles' => $this->titles(),
47 'buttons' => $this->buttons(),
48 'messages' => $this->messages(),
49 'plural' => $this->plural()
50 ) );
51
52 }
53
54 55 56
57 private function titles(){
58 $titles = is_pos_admin() ? $this->admin_titles() : $this->frontend_titles();
59 return $titles + $this->common_titles();
60 }
61
62 63 64
65 private function buttons(){
66 $buttons = is_pos_admin() ? $this->admin_buttons() : $this->frontend_buttons();
67 return $buttons + $this->common_buttons();
68 }
69
70 71 72
73 private function messages(){
74 $messages = is_pos_admin() ? $this->admin_messages() : $this->frontend_messages();
75 return $messages + $this->common_messages();
76 }
77
78 79 80
81 private function plural(){
82 if( !is_pos_admin() ){
83 return array(
84 'records' => _x( 'record |||| records', 'eg: 23 records', 'woocommerce-pos' ),
85 );
86 }
87 }
88
89 90 91
92 private function common_titles(){
93 return array(
94 'more-info' => __( 'More info', 'woocommerce-pos' ),
95
96 'error' => __( 'Error', 'woocommerce' ),
97 );
98 }
99
100 101 102
103 private function admin_titles(){
104 return array();
105 }
106
107 108 109
110 private function frontend_titles(){
111 return array(
112 'browser' => _x( 'Browser', 'system status: browser capabilities', 'woocommerce-pos' ),
113
114 'cart' => __( 'Cart', 'woocommerce' ),
115
116 'checkout' => __( 'Checkout', 'woocommerce' ),
117
118 'coupons' => __( 'Coupons', 'woocommerce' ),
119
120 'customers' => __( 'Customers', 'woocommerce' ),
121
122 'fee' => __( 'Fee', 'woocommerce' ),
123 'hotkeys' => _x( 'HotKeys', 'keyboard shortcuts', 'woocommerce-pos' ),
124
125 'order' => __( 'Order', 'woocommerce' ),
126
127 'orders' => __( 'Orders', 'woocommerce' ),
128
129 'products' => __( 'Products', 'woocommerce' ),
130 'receipt' => __( 'Receipt', 'woocommerce-pos' ),
131
132 'shipping' => __( 'Shipping', 'woocommerce' ),
133 'to-pay' => __( 'To Pay', 'woocommerce-pos' ),
134 'paid' => __( 'Paid', 'woocommerce-pos' ),
135 'unpaid' => __( 'Unpaid', 'woocommerce-pos' ),
136 'email-receipt' => __( 'Email Receipt', 'woocommerce-pos' ),
137 'open' => _x( 'Open', 'order status, ie: open order in cart', 'woocommerce-pos' ),
138 'change' => _x( 'Change', 'Money returned from cash sale', 'woocommerce-pos' ),
139 'support-form' => __( 'Support Form', 'woocommerce-pos' ),
140
141 'system-status' => __( 'System Status', 'woocommerce' ),
142 );
143 }
144
145 146 147
148 private function common_buttons() {
149 return array(
150
151 'save' => __( 'Save Changes', 'woocommerce' ),
152
153 'close' => __( 'Close' ),
154
155 'disable' => __( 'Disable' ),
156
157 'enable' => __( 'Enable' )
158 );
159 }
160
161 162 163
164 private function admin_buttons(){
165 return array(
166 'restore' => _x( 'Restore defaults', 'restore default settings', 'woocommerce-pos' ),
167 );
168 }
169
170 171 172
173 private function frontend_buttons(){
174 return array(
175
176 'checkout' => __( 'Checkout', 'woocommerce' ),
177 'clear' => _x( 'Clear', 'system status: delete local records', 'woocommerce-pos' ),
178
179 'coupon' => __( 'Coupon', 'woocommerce' ),
180 'discount' => __( 'Discount', 'woocommerce-pos' ),
181
182 'email' => __( 'Email' ),
183
184 'fee' => __( 'Fee', 'woocommerce' ),
185
186 'new-order' => __( 'New Order', 'woocommerce' ),
187
188 'note' => __( 'Note', 'woocommerce' ),
189
190 'print' => __( 'Print' ),
191 'process-payment' => __( 'Process Payment', 'woocommerce-pos' ),
192
193 'refresh' => __( 'Refresh' ),
194 'return' => _x( 'return', 'Numpad return key', 'woocommerce-pos' ),
195 'return-to-sale' => __( 'Return to Sale', 'woocommerce-pos' ),
196 'send' => __( 'Send', 'woocommerce-pos' ),
197
198 'shipping' => __( 'Shipping', 'woocommerce' ),
199 'void' => __( 'Void', 'woocommerce-pos' ),
200 'split' => __( 'Split', 'woocommerce-pos' ),
201 'combine' => __( 'Combine', 'woocommerce-pos' ),
202 );
203 }
204
205 206 207
208 private function common_messages(){
209 return array(
210
211 'choose' => __( 'Choose an option', 'woocommerce' ),
212
213 'error' => __( 'Sorry, there has been an error.', 'woocommerce' ),
214 'loading' => __( 'Loading ...', 'woocommerce-pos' ),
215
216 'success' => __( 'Your changes have been saved.', 'woocommerce' ),
217 );
218 }
219
220 221 222
223 private function admin_messages(){
224 return array();
225 }
226
227 228 229
230 private function frontend_messages(){
231 return array(
232 'browser' => __( 'Your browser is not supported!', 'woocommerce-pos' ),
233 'legacy' => __( 'Unable to use RESTful HTTP methods', 'woocommerce-pos' ),
234
235 'no-products' => __( 'No Products found', 'woocommerce' ),
236
237 'cart-empty' => __( 'Your cart is currently empty.', 'woocommerce' ),
238 'no-gateway' => __( 'No payment gateways enabled.', 'woocommerce-pos' ),
239
240 'no-customer' => __( 'Customer not found', 'woocommerce' ),
241 'private-browsing' => sprintf( __( 'WooCommerce POS will not work in <a href="%s">Private Mode</a>, please disable Private Browsing.', 'woocommerce-pos' ), 'https://wikipedia.org/wiki/Privacy_mode' ),
242 );
243 }
244
245 }