Pass String Literals

This topic applies to the Kilimanjaro release of SCA and earlier. If you are localizing text using an extension, see Localize Text in an Extension.

In the following code the string literal, Country is required, is translated to Se requiere pais when the site’s language is set to Spanish. This correlates to the JSON name-value pair defined in the SC.Translations array of the es_ES.js file within the application’s Languages folder.

_.translate() function used in Address.Model.js file:

          validation: {
         ...
      ,   country: { required: true, msg: _('Country is required').translate() }
        ...
      } 

        

Corresponding JSON used in ShoppingApplication@x.x.x >Languages > es_ES.js:

          SC.Translations = {
      ...
"Continue Shopping":"Continuar comprando",  
"Continue Shopping on our $(0)":"Continuar comprando en nuestro $(0)",  
"Country is required":"Se requiere país",  
"Credit Card Number is invalid":"Número de tarjeta de crédito no válido",  
"Credit Card type is not supported":"No se admite el tipo de tarjeta de crédito",
      ...
}; 

        
Note:

Values from the SC.Translations arrays are passed off to a translation function. Therefore, there may not always be a direct relationship between the values set in the SC.Translations array for a specified language and the actual values displayed in your web store.

Many string literals are translated on the client side using the _.translate() function. When a specific language is set for a website, string literals wrapped in any _.translate() functions are replaced with language specific strings. These strings are retrieved from name-value pairs defined in the SC.Translations arrays within the JavaScript files located in the languages directory.

Language JavaScript files are located in the languages subfolder for each application module. For example, Modules > suite_commerce > ShoppingApplication.x.x.x > Languages. In the final Distribution folder, these files are located in the languages subfolder at the root level.

Note:

If a literal wrapped in a _.translate() function does not have a corresponding name-value pair in the SC.Translations array for the active language, that literal is not replaced.

For example, in the following code the string literal Country is required is translated to Se requiere pais when the site’s active language is Spanish. This correlates to the JSON name-value pair defined in the SC.Translations array of the es_ES.js file within the languages folder.

_.translate() function used in Address.Model.js file:

          validation: {
         ...
      ,   country: { required: true, msg: _('Country is required').translate() }
        ...
      } 

        

Corresponding JSON used in ShoppingApplication@x.x.x >Languages > es_ES.js:

          SC.Translations = {
      ...
"Continue Shopping":"Continuar comprando",  
"Continue Shopping on our $(0)":"Continuar comprando en nuestro $(0)",  
"Country is required":"Se requiere país",  
"Credit Card Number is invalid":"Número de tarjeta de crédito no válido",  
"Credit Card type is not supported":"No se admite el tipo de tarjeta de crédito",
      ...
}; 

        
Note:

Values from the SC.Translations arrays are passed off to a translation function. Therefore, a direct relationship may not always exist between the values set in the SC.Translations array for a specified language and the actual values displayed in your web store.

Related Topics

Pass Parameters and HTML
The Translation Process
Set Up NetSuite for Localized Content
Create Custom String Literals
Configure Hosts for Sites with Multiple Languages

General Notices