1

We need to store messages in the database. We could store the English text, but this could be less friendly if a French user wanted to review the messages.

Is there a way I could look up a Custom Label text dynamically in Apex (not using VisualForce) so that I can store the key and arguments in the database and late translate on display?

0

If the messages are known upfront (for example situation where "there are multiple things wrong with this record, integration cannot proceed / record cannot be approved until they're all fixed") you could look into making a multiselect picklist on the record and simply translate the picklist values. Then use describe calls to fetch picklist value & label.

You could create custom labels with error codes or something and fetch them in Apex. There's no nice way to do it dynamically in pure Apex though (workaround by creating dynamic VF component is not really "pure"): possible to access custom labels dynamically?

| improve this answer | |
  • Thanks. We may need to look at something like that. I'll ask how important late translation is. I'd also wondered if I could get VF to output the required labels in a way our Javascript client can read. Not pure, but may be a way. – Richard Corfield Jul 31 '14 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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