Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

We have a requirement to create a force.com site in 2 languages english and spanish. We plan to use custom labels to display content on spanish but our content exceeds more than 5000 custom labels which is a governor limit. What is the other options to display content in spanish other than custom labels? Could you guys share some experiences please? Thanks Buyan

share|improve this question
    
Checking with salesforce to increase the limit for your org won't be bad thought... –  Mohith Shrivastava Feb 8 '13 at 20:20

2 Answers 2

more than 5000 custom labels which is a governor limit.

Never heard of such limit. Are you saying there's limit on how many custom labels there can be? Or how many characters can be in the body of a label?

If it's about too many characters - can't you simply cut your content by paragraph or something? Sounds like a huge "wall of text"...

My next question would be "is this text really, really static?" Custom labels are fine when you have something that's not changing too often. If your users will start complaining "we want to be able to edit it without involving IT, raising a change request ticket, blah blah blah" - it's a good time to check if you wouldn't be better creating some small custom object with 1 field per language (textarea? rich text field?). Or maybe 1 field but several records - the object will have a "language" field too - with just 1 field you'll be able to go all the way to 32K characters.


Normal (authenticated) users can set their own lang in setup. But it is your job to set the language for your Site users (guests who are just browsing the page). http://wiki.developerforce.com/page/An_Introduction_to_Force.com_Sites is a good start (search for "Multi Language Support").

Once you have it as a parameter available in Apex (for example http://.../site.com/lang=es) you can access it in page controller: ApexPages.currentPage().getParameters().get('lang') (but in reality it's your call, you can even have 2 separate sites as long as you can determine the language somehow in Apex based on URL or some passed parameters). Use this to make a query to this custom object, something similar to

String langCode = ApexPages.currentPage().getParameters().get('lang');
if(langCode == null) {
    langCode = 'en';
}

List<TranslatedLabels> labels = [SELECT Content__c 
FROM SiteLabel__c 
WHERE Name IN ('Form 1 text', 'Form 2 text', 'Form 3 text') AND Language_ISO_Code__c = :langCode];

and later in visualforce you'd refer to these as {!labels[0]}

This is of course a very crude example but should give you some ideas ;) For example it might be better to build a map of labelname => actual text and later in VF have {!labelsMap['Form 1 text']}.


SUBSTITUTE etc.

How to populate your text dynamically injecting "Dear John Doe, thank you for your payment..." using SUBSTITUTE, BLANKVALUE etc? You can read about these and many more functions here - most of them works in formulas as well as Visualforce.

Example scenario: I need to send a simple translated email to a Contact. If Contact is attached to the record and I can use it - awesome. If there's no Contact (my user just typed the email address by hand instead of making a new COntact and linking it) - it should fall back to "Dear Sir or Madam" instead of "Dear John Doe".

I have 2 custom labels:

SA_Email_Body: Dear [contact], 
Please find attached a copy of the Annual Service Audit that we conducted for your information and further use. 
Kind regards,

SA_Default_Salutation: Sir or Madam

And in Spanish (European) they're translated to:

SA_Email_Body: Estimado [contact], 
Adjunto encontrará para su información una copia de la Auditoría de Postventa Anual que se le ha realizado. 
Un saludo.

SA_Default_Salutation: Señor o señora

And here's my email template:

{!SUBSTITUTE($Label.SA_Email_Body, '[contact]', BLANKVALUE(recipient.Name, $Label.SA_Default_Salutation))}
{!$User.FirstName} {!$User.LastName}
{!$Organization.Name}

Looks a bit scary but I simply replace the [contact] placeholder and attach current user's data at the end. I don't know if you'll have Contacts available on your site, it's for guests after all... but you need some way of capturing their data anyway so just adjust the merge fields to point to your controller variables or something.

share|improve this answer
    
I think your suggestion of storing in a custom object might work. We have many forms with field labels to be populated in spanish and they go beyond 5000 form fields. We also have content which needs to be populated at run time like "Thanks mrxxx, we cannot approve your amount to your child xxx where the xxx values would need to be pulled at runtime. How can i store spanish content in a custom object? even if i store, how can i query and display it on a spanish page? Is there any example of source code you can share please on it? –  buyan kumar Feb 9 '13 at 0:49
    
Can you send me some examples of how to use the substitute function please or urls with sample code? –  buyan kumar Feb 10 '13 at 4:46
1  
I did but man, you're stretching it ;) I doubt this question will be of good value to other visitors if it talks about everything from sites & custom labels to custom objects and merge fields functions ;) –  eyescream Feb 10 '13 at 10:09
    
eyescream there are limits: "You can create up to 5,000 custom labels for your organization, and they can be up to 1,000 characters in length." src: login.salesforce.com/help/doc/en/cl_about.htm –  Samuel De Rycke Feb 10 '13 at 11:46
    
Thx @Sdry, good to know! Still - I've never hit it and I wouldn't call it "governor limit" ;) I suspect it's something they'll be slowly increasing (like picklists used to have max 500 values, now 1000, amount of custom fields on an object also went up eventually...) –  eyescream Feb 10 '13 at 12:12

If you think Custom Objects to do this, Custom Settings is a better way forward. Custom Settings are cached in memory and Custom Objects require a query. Performance of your webpage would be better. Besides that, if you are using a Communities license or a Force.com license, a Custom Object would count against the number of Custom Objects you bought (standard 10 for both Communities license models as Force.com).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.