Skip to main content
Reference

I18n SFO

Basic Example Usage:

$i18n.write("checkout.viewcart.yourContactEmailField", "Your contact email")

See Also: How StoreFront handles static text and multi-lingual support

Properties

FieldTypeComment/Sample

Methods

MethodReturnsParametersParameter TypesComment/Sample
escapestringinputbooleanReturns the text "true" or "false" based upon the boolean input parameter.
escapestringinputstringTakes a block of text and html escapes it so it can be safely added to a web page without causing harm.
Example:
#foreach($error in $formSupport.errors) #if($error.alreadyEscaped)$!error.message#{else}$i18n.escape($error.message)#{end}<br /> #end
getCurrencies[I18NCurrency](./i18ncurrency-sfo.md)[]Returns back a list of supported currencies. The names of the currencies are translated into the language that the customer is using.
getLanguages()[I18NLanguage](./i18nlanguage-sfo.md)[]Returns back a list of support languages. The languages are each translated into the native way the language is spelled. Used by the language picker.
getPopularLanguages()[I18NLanguage](./i18nlanguage-sfo.md)[]countryCodestringGiven a two letter ISO country code, return the languages that are popular that country. Used by the language picker.
getUnpopularLanguages()[I18NLanguage](./i18nlanguage-sfo.md)[]countryCodestringGiven a two letter ISO country code, return back all the languages that are considered unpopular for a country. Used by the language picker.
getIsoCodestringreturns back the current ISO Code for the page. Default is ENG.
getJavaScriptHashstringreturns a JavaScript has object created by all the calls to pushJavaScriptHash. These two methods work together to create a hash map of translated text used by dynamic elements on the page, such as the cart snapshot, which still need to display translated content.
htmlLangstringkeystringGenerates the lang attribute associated with this key. The lang attribute is used to identify what type of translation has occurred for a given element and is required by Google when auto translation is used.
ignoreHtmlLangvoidkeystringRegisters that we want to ignore outputting an htmlLang call for a given key. Prevents an i18n violation from being generated. Also registers the key for use by a subsequent shorthand write call.
isGoogleTranslateUsedbooleanReturns true if any text on the page was automatically translated by Google Translate. Used for displaying the attribution mark in the footer.
newlineToBreaksstringinputstringTakes a block of text and converts all newlines to <br /> tags so that the text remains consistent rendered in html.
pushJavaScriptHashvoidkey
defaultText
args..
string
string
string...&nbsp;
This method is similar to a write call, but will queue up the entry which is returned by getJavaScriptHash.
writestringdefaultMessagestringThe key associated with this write call is the one last used on an htmlLang or ignoreHtmlLang call. It enables a shorter syntax in the template.
writestringdefaultMessage
escape
string
boolean
The key associated with this write call is the one last used on an htmlLang or ignoreHtmlLang call. It enables a shorter syntax in the template.
if true, the return value is html escaped first
writestringkey
defaultMessage
string
string
key is the full dot separated path to the message key as found in the language file. Example: checkout.accessaccount.emailField
If the key isn't found, this default is used instead
writestringkey
defaultMessage
args...
string
string
string...&nbsp;
key is the full dot separated path to the message key as found in the language file. Example: checkout.accessaccount.emailField
If the key isn't found, this default is used instead
Arguments to merge into the message. {0} = first argument place holder, {1} = second argument place holder, etc.
writestringkey
defaultMessage
escape
string
string
boolean
key is the full dot separated path to the message key as found in the language file. Example: checkout.accessaccount.emailField
If the key isn't found, this default is used instead
if true, the return value is html escaped first

See Also

Was this page helpful?