function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

i18n in S-Control

We, multi-byte language users, are always worrying about SControl-based AppX apps which are only written in English and requires enourmous amount of time to translate them to local language. Native apps, on the other hand, is a bit easier because all resources are separated in metadata.

Are there any best-practices for making SControl apps with i18n? If you don't have right now, let's consider how they should be like? I hope some knowledgable guys in this area would return some comments...
OK, I can't get any comments...:smileysad: Anyway, I'll post here what I'm now doing for i18n.

1. I18N resources are separated in JSON format, like this

var _resources = {
  "en" : {
    "title.main" : "Main Title", 
    "header.no1" : "Header #1", 
    "header.no2" : "Header 2",
    "error.accessNotAllowed" : "Access not allowed."

  "ja" : {
    "title.main" : "\u30e1\u30a4\u30f3\u30bf\u30a4\u30c8\u30eb", // Unicode escaped str
    "header.no1" : "\u30d8\u30c3\u30c0 \uff03\uff11", 
    "header.no2" : "\u30d8\u30c3\u30c0 \uff03\uff12",
    "error.accessNotAllowed" : "\u30a2\u30af\u30bb\u30b9\u306f\u8a31\u53ef\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002"


2. When S-Control is loaded, automatically gets current user language via getUserInfo()

var lang = sforce.connection.getUserInfo().userLanguage;

3. Define getResource() function to retrieve i18n message resource :

function getResource(resourceName) {
  return _resources[lang] && _resources[lang][resourceName] — _resources[lang][resourceName] :
         _resources['en'][resourceName] – _resources['en'][resourceName] : 

4. Use getResource() function when message is needed in S-Control.