Hi, guys!
Recently, I learn how to write custom tasks for EG using C#. Now, I have already finished one, the UI language is English. How to add another language, like the original task:
It has Chinese and English two language.
What should I do? Hope you guys give me a demo project, Thanks!
Eric,
There are a few steps to make this work. I'll summarize them here and hope that gets you started. I may write a longer article on this topic if it's of interest.
The way .NET works, you can supply an alternative language for your application user interface by creating a satellite assembly. In the EG install folder, you'll see these assembly files (DLLs) in culture-specific subfolders (such as zh-CN for Simplified Chinese).
The satellite assemblies are small, and contain only language-specific resources such as message strings and UI pieces, no programming logic. There are lots of tools and approaches for creating these. Some are point-and-click localizations tools, or some simply use .NET SDK-level tools. Here's one resource - but you can search for others: .NET Localization, Part 2: Creating Satellite Assemblies - O'Reilly Media
Satellite assemblies are good only when you actually externalize the localizable pieces outside of the program code. For the task class (inherited from SAS.Tasks.Toolkit.SasTask), you can put the class into the Designer view in Visual Studio and change the Localizable property to True. You would do the same for any part of the task that has a UI: Windows forms, controls, etc.
For messages, you will need to put the message strings into a resource file (ex: Resources.resx) and then reference those resources from within your code instead of the literal strings.
With a satellite assembly built, you need to put it in a directory where the .NET runtime will find it. Usually you place it in a subfolder relative to the location of the task DLL, using the culture-specific name for the folder. For example, for Traditional Chinese you put place it in a "zh-CN" folder. If you want one set of resources to serve all Chinese users, you could place it in the more generic "zh" folder. The .NET runtime will load the most specific resource that it can find to match the current runtime culture. If none are found, it will fall back to the "culture neutral" resource that is built into the main task DLL (usually English).
I hope that helps as a starting point.
Chris
Eric,
There are a few steps to make this work. I'll summarize them here and hope that gets you started. I may write a longer article on this topic if it's of interest.
The way .NET works, you can supply an alternative language for your application user interface by creating a satellite assembly. In the EG install folder, you'll see these assembly files (DLLs) in culture-specific subfolders (such as zh-CN for Simplified Chinese).
The satellite assemblies are small, and contain only language-specific resources such as message strings and UI pieces, no programming logic. There are lots of tools and approaches for creating these. Some are point-and-click localizations tools, or some simply use .NET SDK-level tools. Here's one resource - but you can search for others: .NET Localization, Part 2: Creating Satellite Assemblies - O'Reilly Media
Satellite assemblies are good only when you actually externalize the localizable pieces outside of the program code. For the task class (inherited from SAS.Tasks.Toolkit.SasTask), you can put the class into the Designer view in Visual Studio and change the Localizable property to True. You would do the same for any part of the task that has a UI: Windows forms, controls, etc.
For messages, you will need to put the message strings into a resource file (ex: Resources.resx) and then reference those resources from within your code instead of the literal strings.
With a satellite assembly built, you need to put it in a directory where the .NET runtime will find it. Usually you place it in a subfolder relative to the location of the task DLL, using the culture-specific name for the folder. For example, for Traditional Chinese you put place it in a "zh-CN" folder. If you want one set of resources to serve all Chinese users, you could place it in the more generic "zh" folder. The .NET runtime will load the most specific resource that it can find to match the current runtime culture. If none are found, it will fall back to the "culture neutral" resource that is built into the main task DLL (usually English).
I hope that helps as a starting point.
Chris
Thanks, Chirs!
Satellite assembly is a good thing, I am learning it, now I am familiar with it. If you write a longer article on this topic, that's best!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.