Overview
  • Namespace
  • Class

Namespaces

  • None
  • WC_POS
    • Admin
      • Settings
        • Receipt
    • API
    • Gateways
    • Integrations
    • Products

Classes

  • WC_POS\Activator
  • WC_POS\Admin
  • WC_POS\Admin\Gateways
  • WC_POS\Admin\Menu
  • WC_POS\Admin\Notices
  • WC_POS\Admin\Orders
  • WC_POS\Admin\Page
  • WC_POS\Admin\Permalink
  • WC_POS\Admin\Plugins
  • WC_POS\Admin\Products
  • WC_POS\Admin\Settings
  • WC_POS\Admin\Settings\Access
  • WC_POS\Admin\Settings\Checkout
  • WC_POS\Admin\Settings\Customers
  • WC_POS\Admin\Settings\Gateways
  • WC_POS\Admin\Settings\General
  • WC_POS\Admin\Settings\HotKeys
  • WC_POS\Admin\Settings\Page
  • WC_POS\Admin\Settings\Receipt\Options
  • WC_POS\Admin\Settings\Receipt\Template
  • WC_POS\Admin\Settings\Receipts
  • WC_POS\Admin\Settings\Status
  • WC_POS\Admin\Settings\Tools
  • WC_POS\Admin\Status
  • WC_POS\Ajax
  • WC_POS\API
  • WC_POS\API\Coupons
  • WC_POS\API\Customers
  • WC_POS\API\Gateways
  • WC_POS\API\i18n
  • WC_POS\API\Orders
  • WC_POS\API\Params
  • WC_POS\API\Payload
  • WC_POS\API\Products
  • WC_POS\API\Settings
  • WC_POS\API\Support
  • WC_POS\API\Templates
  • WC_POS\Customers
  • WC_POS\Deactivator
  • WC_POS\Gateways
  • WC_POS\Gateways\Card
  • WC_POS\Gateways\Cash
  • WC_POS\i18n
  • WC_POS\Integrations\Bookings
  • WC_POS\Products
  • WC_POS\Products\Visibility
  • WC_POS\Setup
  • WC_POS\Status
  • WC_POS\Tax
  • WC_POS\Template

Functions

  • is_pos
  • is_pos_admin
  • wc_pos_get_option
  • wc_pos_json_encode
  • wc_pos_locate_template
  • wc_pos_trim_html_string
  • wc_pos_update_option
  • wc_pos_url
  1 <?php
  2 
  3 /**
  4  * i18n values
  5  *
  6  * @class    WC_POS_API_i18n
  7  * @package  WooCommerce POS
  8  * @author   Paul Kilmurray <paul@kilbot.com.au>
  9  * @link     http://www.woopos.com.au
 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    * Register routes for POS Params
 23    *
 24    * GET /pos
 25    *
 26    * @param array $routes
 27    * @return array
 28    */
 29   public function register_routes( array $routes ) {
 30 
 31     # GET /pos/i18n
 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    * @return array
 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    * @return array
 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    * @return array
 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    * @return array
 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    * @return array
 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    * @return array
 91    */
 92   private function common_titles(){
 93     return array(
 94       'more-info' => __( 'More info', 'woocommerce-pos' ),
 95       /* translators: woocommerce */
 96       'error'     => __( 'Error', 'woocommerce' ),
 97     );
 98   }
 99 
100   /**
101    * @return array
102    */
103   private function admin_titles(){
104     return array();
105   }
106 
107   /**
108    * @return array
109    */
110   private function frontend_titles(){
111     return array(
112       'browser'       => _x( 'Browser', 'system status: browser capabilities', 'woocommerce-pos' ),
113       /* translators: woocommerce */
114       'cart'          => __( 'Cart', 'woocommerce' ),
115       /* translators: woocommerce */
116       'checkout'      => __( 'Checkout', 'woocommerce' ),
117       /* translators: woocommerce */
118       'coupons'       => __( 'Coupons', 'woocommerce' ),
119       /* translators: woocommerce */
120       'customers'     => __( 'Customers', 'woocommerce' ),
121       /* translators: woocommerce */
122       'fee'           => __( 'Fee', 'woocommerce' ),
123       'hotkeys'       => _x( 'HotKeys', 'keyboard shortcuts', 'woocommerce-pos' ),
124       /* translators: woocommerce */
125       'order'         => __( 'Order', 'woocommerce' ),
126       /* translators: woocommerce */
127       'orders'        => __( 'Orders', 'woocommerce' ),
128       /* translators: woocommerce */
129       'products'      => __( 'Products', 'woocommerce' ),
130       'receipt'       => __( 'Receipt', 'woocommerce-pos' ),
131       /* translators: woocommerce */
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       /* translators: woocommerce */
141       'system-status' => __( 'System Status', 'woocommerce' ),
142     );
143   }
144 
145   /**
146    * @return array
147    */
148   private function common_buttons() {
149     return array(
150       /* translators: woocommerce */
151       'save'    => __( 'Save Changes', 'woocommerce' ),
152       /* translators: wordpress */
153       'close'   => __( 'Close' ),
154       /* translators: wordpress */
155       'disable' => __( 'Disable' ),
156       /* translators: wordpress */
157       'enable'  => __( 'Enable' )
158     );
159   }
160 
161   /**
162    * @return array
163    */
164   private function admin_buttons(){
165     return array(
166       'restore'         => _x( 'Restore defaults', 'restore default settings', 'woocommerce-pos' ),
167     );
168   }
169 
170   /**
171    * @return array
172    */
173   private function frontend_buttons(){
174     return array(
175       /* translators: woocommerce */
176       'checkout'        => __( 'Checkout', 'woocommerce' ),
177       'clear'           => _x( 'Clear', 'system status: delete local records', 'woocommerce-pos' ),
178       /* translators: woocommerce */
179       'coupon'          => __( 'Coupon', 'woocommerce' ),
180       'discount'        => __( 'Discount', 'woocommerce-pos' ),
181       /* translators: wordpress */
182       'email'           => __( 'Email' ),
183       /* translators: woocommerce */
184       'fee'             => __( 'Fee', 'woocommerce' ),
185       /* translators: woocommerce */
186       'new-order'       => __( 'New Order', 'woocommerce' ),
187       /* translators: woocommerce */
188       'note'            => __( 'Note', 'woocommerce' ),
189       /* translators: wordpress */
190       'print'           => __( 'Print' ),
191       'process-payment' => __( 'Process Payment', 'woocommerce-pos' ),
192       /* translators: wordpress */
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       /* translators: woocommerce */
198       'shipping'        => __( 'Shipping', 'woocommerce' ),
199       'void'            => __( 'Void', 'woocommerce-pos' ),
200       'split'           => __( 'Split', 'woocommerce-pos' ),
201       'combine'         => __( 'Combine', 'woocommerce-pos' ),
202     );
203   }
204 
205   /**
206    * @return array
207    */
208   private function common_messages(){
209     return array(
210       /* translators: woocommerce */
211       'choose'      => __( 'Choose an option', 'woocommerce' ),
212       /* translators: woocommerce */
213       'error'       => __( 'Sorry, there has been an error.', 'woocommerce' ),
214       'loading'     => __( 'Loading ...', 'woocommerce-pos' ),
215       /* translators: woocommerce */
216       'success'     => __( 'Your changes have been saved.', 'woocommerce' ),
217     );
218   }
219 
220   /**
221    * @return array
222    */
223   private function admin_messages(){
224     return array();
225   }
226 
227   /**
228    * @return array
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       /* translators: woocommerce */
235       'no-products' => __( 'No Products found', 'woocommerce' ),
236       /* translators: woocommerce */
237       'cart-empty'  => __( 'Your cart is currently empty.', 'woocommerce' ),
238       'no-gateway'  => __( 'No payment gateways enabled.', 'woocommerce-pos' ),
239       /* translators: woocommerce */
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 }
API documentation generated by ApiGen