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
localequery parameter, which is then stored in acustom_site_localecookie. The cookie is used in future requests that use this source if nolocalequery parameter is provided. You can check this via thesquare.site.current_localeproperty. Note that this value is only used if it’s a supported Square Online locale, otherwiseHTTPwill fallback to using the site locale that’s configured in the Square Online dashboard (equivalent to theSITEsource) andsquare.site.current_localewill 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
- The supported Square Online locales are:
- SITE - Uses the site’s locale that is configured in the Square Online dashboard. This is available on the
localeproperty 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.