Optimizely B2B Commerce integrates Multi-Language and Translation capabilities directly into its Content Management System (CMS). These tools empower site administrators to define the website display language for users, and create unique content by language code, device type, and user persona. This functionality supports all Unicode languages, with the exception of languages that have right to left presentation (such as Hebrew and Arabic).
Database collation is only important for non-unicode datatypes (char, varchar). As B2B Commerce supports Unicode, database collation is not a concern.
Website users may view the site in any languages marked as "Live" under the website's Languages tab. When an anonymous user browses the site, the site automatically is displayed in that user's browser's default language code, if available. If that language is not available on the site, the website's default language is displayed.
When a user is logged in, the user sees the language compatible with the language code defined in their Admin Console user record. The user's language is only used when impersonating the user. The user's default language is not used on the site when the user visits it, because we assume the user will select the language they prefer on the site before signing in, so we do not want to change their selected language.
Users may change the displayed language via the Language Selector menu on the website's header.
If the user chooses a language via the Language Selector menu, this selection is saved in the browser's cookie. Each time the user views the site with that browser, the language defined within the cookie is displayed.
If no translation is available within the selected language for a section of text, text from the website's default language is displayed. This same hierarchy exists for content properties related to Persona and Device Type.
In B2B Commerce, home pages for multi-language sites have unique URLs. The language code will appear at the end of the home page URL for each language.
Hreflang attribute for SEO
For all multi-language sites, the URL tags for all storefront webpages, sitemaps, and pages themselves contain the hreflang attribute. This attribute identifies the specific language on the page for search engines, thus enabling search engines to serve relevant language results to users searching in that language.
The value of the hreflang attribute automatically populates based on the Language Code field on the Administration > Localization > Languages page. See Creating a new language.
URL example for a sitemap
<url> <loc>https://commerce.local.com/Catalog/TestCategoryBoost2 <lastmod>2018-01-23T15:24:12+00:00</lastmod> <changefreq>monthly</changefreq> <priority>0.8</priority> <xhtml:link rel="alternate" hreflang="es-mx" href="https://commerce.local.com/Catalog/TestCategoryBoost2?setcontextlanguagecode=es-mx" /> <xhtml:link rel="alternate" hreflang="en-us" href="https://commerce.local.com/Catalog/TestCategoryBoost2?setcontextlanguagecode=en-gb" /> <xhtml:link rel="alternate" hreflang="fr-fr" href="https://commerce.local.com/Catalogue/TestCategoryBoost2?setcontextlanguagecode=fr-ca" /> </url>
URL example for a content page
<url> <loc>https://commerce.local.com/ContactUs</loc> <lastmod>2016-04-14T21:57:02+00:00</lastmod> <changefreq>monthly</changefreq> <priority>0.5</priority> <xhtml:link rel="alternate" hreflang="es-mx" href="https://commerce.local.com/ContactUs?setcontextlanguagecode=es-mx" /> <xhtml:link rel="alternate" hreflang="en-us" href="https://commerce.local.com/ContactUs?setcontextlanguagecode=en-gb" /> <xhtml:link rel="alternate" hreflang="fr-fr" href="https://commerce.local.com/ContactUs?setcontextlanguagecode=fr-ca" /> </url>
B2B Commerce has two options for managing translations: Field Translations and the Translation Dictionary. Field translations are for individual fields found on commerce objects, such as Products, Promotions, or Categories. An example would be providing a translation for the Product Title of a particular Product. The Translation Dictionary manages translations for things such as messages, attributes, attribute values, units of measure, and labels. For example, providing a translation for the unit of measure of Each.
Generally stated, field translations are more granular in nature and are orientated toward individual records, whereas the Translation Dictionary is more global in nature and provides translations for text that is shared across the website.