What’s New
Have you noticed the Autodesk Exchange Store in many more languages? The store is now available for a much bigger audience in many languages: i.e. Čeština, Deutsch, Français, Español, Magyar, Italiano, 日本語, 한국어, Polski, Português, Русский, 简体中文 and 繁體中文. The following image shows how the Revit Store looks like, for example, in Portuguese.
If you access the store from your browser, it will show according to the browser’s language settings. If the user clicks on the “X” symbol from the product’s UI, it will call the the browser and show it using the language of Revit that you are running. installation language. Below is an image with the “X” button and respective link for Revit 2014 Portuguese (note that language equals pt, mean that it is Portuguese).
Tip: if you want to point to your application on the store (e.g. from your website), just include the language code in the link. If you don’t, it will open the page in the language following the browser settings.
Creating Multi-language Revit Applications
First, if you plan to design a application that is on just one language, then you can skip to ‘Preparing the .bundle folder’ section. In such a case you just need to publish to the proper store. Your application can have the interface in one language.
Creating multi-language application means that will load the appropriate interface depending on the system configuration. And that’s what will be shown here.
The most basic approach consists in making the .addin file load the correct language string according to Revit language. This is described in this wiki help topic. This is interesting, but will only affect the items under ‘External Commands’ menu – at the main ribbon. The Autodesk Exchange Apps - Information for Autodesk Revit Developers states that, among other requirements, your app must have one Ribbon Button (at least), so the ‘External Commands’ does not apply here. We need the External Application definition.
Let’s start a project with the Revit 2014 template or an existing project. Create a new item of type ‘Resource File’ and, here is the trick: put the language code on the file name; for instance:
- MyAppResource.en-US.resx
- MyAppResource.pt-BR.resx
- any other you need to support, see a full list here.
Now on each resource.LANGUAGE.resx file, add a list of resources strings, such as CommandName, CommandDescription, PanelName and HelpFile Below is a sample for Portuguese.
Once you finish creating all the language resources, create a another file with no language specification, for this case, just MyAppResource.resx. Open it and choose ‘Access Modifier’ as ‘Internal’, as shown on the image below. This will make Visual Studio create a class to access the resources according to Revit language.
Important: remember to deploy your application DLL and the language folders, in this sample en-US and pt-BR. These folders must be at the app DLL folder, otherwise Revit will not recognize them.
Now it’s time to write some code.
To create a panel with buttons there is no major changes, except that the String names will come from the resource manager, following the current execution language. Below is a sample code for creating a new Panel, a Button (no image, for brevity) and the help file. Note the class MyAppResource we declared is used to load the resource easily.
public Result OnStartup(UIControlledApplication application)
{
// current execution assembly location
System.Reflection.Assembly dotNetAssembly =
System.Reflection.Assembly.GetExecutingAssembly();
// Create a new panel
RibbonPanel pnl = application.CreateRibbonPanel(
MyAppResource.ResourceManager.GetString("PanelName"));
// Create the command button
PushButtonData cmd1 = new PushButtonData(
"COMMAND1",
MyAppResource.ResourceManager.GetString("Command1Name"),
dotNetAssembly.Location,
typeof(Command1).FullName);
// Command description
cmd1.LongDescription =
MyAppResource.ResourceManager.GetString("Command1Description");
// set help file
ContextualHelp contextHelp = new ContextualHelp(
ContextualHelpType.ChmFile,
System.IO.Path.GetDirectoryName(dotNetAssembly.Location)
+ "/Resources/"
+ MyAppResource.ResourceManager.GetString("HelpFile"));
cmd1.SetContextualHelp(contextHelp);
// add the new button to the panel.
pnl.AddItem(cmd1);
return Result.Succeeded;
}
That’s it! Now the app will load the interface according to Revit language. The image below shows the result. Fantastic! This is a .NET feature, by the way.
Preparing the .bundle Folder
Now create a .bundle folder. For this sample let’s call the app as “ADN Revit Global Product.bundle”. We suggest you create a Contents subfolder, then Win2014 subfolder (if you support more version and the app is not binary compatible, create a separated folder for each version). Copy the \bin\Release output content from Visual Studio content, as shown on the image below. The .addin file should be copied here. Finally the Resource subfolder will contain the Help files, and any other resource you might use.
And the PackageContents.xml can be like shown below. Note that a few tags have the PTB suffix. The SupportedLocales indicates in which languages the installer should be created. And, as usual, only the .addin file is included on the component entry section.
<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage SchemaVersion="1.0"
AutodeskProduct="Revit"
Name="Revit Global Product"
Description="Testing multilanguage app for Revit"
DescriptionPtb="Teste de aplicação multi-idioma para Revit"
AppVersion="1.0.0" FriendlyVersion="1.0.0"
ProductType="Application"
Author="ADN"
HelpFile="./Contents/Win2014/Resources/HelpFile.htm"
HelpFilePtb="./Contents/Win2014/Resources/ArquivoAjuda.htm"
SupportedLocales="Enu|Ptb"
AppNameSpace="appstore.exchange.autodesk.com"
OnlineDocumentation="http://www.autodesk.com"
OnlineDocumentationPtb="http://www.autodesk.com.br">
<CompanyDetails Name="ADN"
Url="http://www.autodesk.com"
Email="[email protected]" />
<RuntimeRequirements
OS="Win32|Win64"
Platform="Revit|Revit Architecture|Revit Structure|Revit MEP"
SeriesMin="R2014" SeriesMax="R2014" />
<Components Description="2014 files">
<RuntimeRequirements
OS="Win32|Win64"
Platform="Revit|Revit Architecture|Revit Structure|Revit MEP"
SeriesMin="R2014" SeriesMax="R2014" />
<ComponentEntry AppName="RevitGlobalProduct"
Version="1.0.0"
ModuleName="./Contents/Win2014/RevitAddin_Localization.addin"
AppDescription="Main .addin file" />
</Components>
</ApplicationPackage>
The supported language codes are:
- Chs - Chinese Simplified (PRC)
- Cht - Chinese Traditional (Taiwan)
- Csy – Czech
- Deu – German
- Enu – English
- Esp – Spanish
- Fra – French
- Hun – Hungarian
- Ita – Italian
- Jpn – Japanese
- Kor – Korean
- Plk – Polish
- Ptb – Portuguese
- Rus - Russian
With that .bundle folder, you are ready to submit your multi-language app to the Autodesk Exchange Store. Once you do so, we’ll create a MSI that work according to the user language. Nice!
Additional topics