There are plenty of things to keep in mind when trying to allow translation, localization and internationalization (t8n, l10n, i18n) in any framework. Salesforce has a whole infrastructure built around creating a good experience for this including Custom Labels, user-level localization settings, and Translation Workbench.
What are the best practices and tricky points for a Salesforce developer and administrator looking to build translatable, localizable, and interanationalizable software?
Best Answer
This is a community wiki. Feel free to add to it!
Please excuse the overly Americentric examples here.
Overriding Principals
Do not require the programmer to know the details of every language or locale that you plan to support.
Make the system flexible enough to allow an admin with fluency in the domain and any given locale* to provide a meaningful interface for users of that locale.
Custom Labels
'Please enter the first ' + numChars + ' characters'
) then useString.format
to allow translators to fill in details or<apex:outputText>
Dates and times
MM/dd/yyyy
ordd/MM/yyyy
) anywhere.Picklists
getValue
andgetLabel
getValue
for internal processes, andgetLabel
for presentation.TOLABEL()
function in SOQL queries for presentationObject Names and Field Labels
$ObjectType
notation (e.g.,{!$ObjectType.Account.Fields.Name.Label}
or{!$ObjectType.Account.Fields.Name.LabelPlural}
) for labels that are simply the name of the relevant field/object.X-Localization SObjects
When you turn on Translation Workbench, you get new objects for the following objects all suffixed by "Localization":
They all have the same usable fields: Language, ParentId, Value. You should use these when providing the user with lists of these objects instead of using the original objects.
Record Types
Front-end
global
service that you can call to translate appropriately within the Translation Workbench framework.ENCODE
HTMLENCODE
,JSENCODE
andJSINHTMLENCODE
liberally in any literal HTML/JS your Visualforce pages.Don't rely on literals
Ensure that you are not relying on literals whenever it is possible to avoid.
Testing
Test it all out with a fine-toothed comb and a native speaker.
* I am defining "locale" here in the general sense - A nebulous combination of language, datetime formats, currency, timezones, dialect and perhaps some cultural expectations.