How to: Use localization

Any Twig filter that involves localization can take in an optional localization source property, with HTTP being the default. These are the following sources that are available:

  • HTTP - Uses the locale query parameter, which is then stored in a custom_site_locale cookie. The cookie is used in future requests that use this source if no locale query parameter is provided. You can check this via the square.site.current_locale property. Note that this value is only used if it’s a supported Square Online locale, otherwise HTTP will fallback to using the site locale that’s configured in the Square Online dashboard (equivalent to the SITE source) and square.site.current_locale will be an empty string.
    • The supported Square Online locales are:
      • ca_ES
      • da_DK
      • de_DE
      • en_AU
      • en_CA
      • en_IE
      • en_GB
      • en_US
      • es_ES
      • es_US
      • fr_CA
      • fr_FR
      • it_IT
      • ja_JP
      • ko_KR
      • no_NO
      • nl_NL
      • pl_PL
      • pt_PT
      • ru_RU
      • sv_SE
      • tr_TR
      • zh_TW
      • zh_CN
  • SITE - Uses the site’s locale that is configured in the Square Online dashboard. This is available on the locale property on the StoreInfo resource.
  • USER - Uses the user’s (i.e. seller’s) locale. This is typically used for work involving the seller facing editor.

The following filters currently support taking in a localization source:

Any resource in the schema, resource functions in the Twig templates, and resource/cart APIs will currently use the SITE source for localization of the returned properties.