Desktop productivity for business analysts and programmers

How to write two language in EG custom tasks?

Accepted Solution Solved
Reply
Contributor
Posts: 64
Accepted Solution

How to write two language in EG custom tasks?

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.

QQ截图20130124144329.png

What should I do? Hope you guys give me a demo project, Thanks!


Accepted Solutions
Solution
‎01-24-2013 04:35 PM
Community Manager
Posts: 2,707

Re: How to write two language in EG custom tasks?

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

View solution in original post


All Replies
Solution
‎01-24-2013 04:35 PM
Community Manager
Posts: 2,707

Re: How to write two language in EG custom tasks?

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

Contributor
Posts: 64

Re: How to write two language in EG custom tasks?

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!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 419 views
  • 1 like
  • 2 in conversation