RSS Amplifier

Lessons in Localization by Eric Silberstein · Mar 29, 2023

C# String Localization using Satellite Assembly

0
Sign in to vote or save

Eric · Lessons in Localization by Eric Silberstein

Internationalization and localization are processes that make software applications accessible and usable to people from different parts of the world.

In C#, internationalization and localization can be achieved through the use of satellite assemblies. First time hearing the term? It’s basically a resource file that an application fetches depending on the user’s language and culture settings. The resources stored in the satellite assembly are used by the application to display text and other types of content in the correct language and format.

To create a localized version of a C# program, developers can create resource files for each language and culture they want to support. In my app, I named my resource files with the prefix of lang, then a period and the respective ISO code. For Spanish Puerto Rico, it was lang.es-PR.resx. Each resource file contained the translations for the ISO code in its name.

After creating and translating resource files (using Lokalise of course!), I used the C# CultureInfo class to set the CurrentUICulture of the application to the culture that the user input in the form of ISO codes. The CurrentUICulture property specifies the resource file that the application should use for fetching the strings.

By using resource files and satellite assemblies, developers can create applications that can be localized to different languages and cultures without having to modify the application code. Theoretically, I can code once, and the localize into the HUNDREDS of languages the C# supports out of the box with minimal changes to my code. Cool, right?

Read the original on ericsilberstein1.substack.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.