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
daniel.duartedaniel.duarte 

Translation Workbench / Formatting Date and Currency

Hello,

I have a few doubts concerning internationalization and translation issues. First: How does the Translation Workbench work? I mean, when we use translation definitions, it translates to what language? Is it the user's browser language, or the user's language in the Salesforce platform, or what? I want to test this feature, so I need to change my settings and see if the page changes showing the labels translated, so I want to know what settings should I change.

The second question I have is if it is possible to have a similar behavior in number, currency and date fields. Is it possible to change the currency or date format based on the user's location or language? Can I change, for example, the decimal separator from dot to comma dynamically, depending on the user's language? Can it be done using Apex?

Thanks

jhurstjhurst

So the Translation Workbench is all based on the salesforce.com user's language (in setup).  So if you have a custom object, and you create translation definitions for the object in French, then your users who have their salesforce.com user language set to French will see the definitions you created.  Users with any other language setting, will see the default values.  To test, simply change your user language (Setup | My Personal Information | Personal Information).

 

The number and date formats are all determined by the user's locale setting in their user information.  So, if the user has their locale set to "French (France, Euro)", then dates will be in the format DD/MM/YYYY and decimals will use commas.  For currency, it is a bit different.  If you have a single currency in your org, the admin set up the display of how the currency will display (regardless of user locale).  If you are in a multi-currency org, then the currency will be shown depending on the user's preferences.

 

For more information, please see the Help & Training:

 

https://help.salesforce.com/apex/HTViewHelpDoc?language=en&id=admin_language_locale_currency.htm

https://na1.salesforce.com/help/doc/user_ed.jsp?section=help&loc=help&target=admin_language_locale_currency.htm%23topic-title

 

Hope this helps

Jay

daniel.duartedaniel.duarte

Thanks, that helped a lot. But I still have a few questions.

How can I use the number formats determined by the user's locale setting in custom VF pages?

It worked as you explained in the default pages, but if I try to show a number field in a custom page the number format isn't the one determined by the user locale. I will give you an example. If I have the following variable in a controller extension for my VF custom page:

public Double x {
   get
   {
      if (x == null)
      x = 1234.40;
      return x;
   }
   set;
}

and I show it in the page using

{!x}

what is shown is 1234.4, even if the locale defines that decimals should use commas.

The same happens for custom number fields. *EDIT: if i use apex:outputField it works

Can I set the number format through Apex or in VisualForce using the user's locale setting?

jhurstjhurst

That is correct.  Visualforce can only apply translation and local display settings to data that is bound to a salesforce.com outputField tag.  Everything else will be displayed in HTML format.  So, to display the locale specific format, you would have to bind the value to apex:outputField, or do the formatting yourself.