0

This code is working for the English language, but when the language is different all the logic will break, how can it be replaced.

if (statuscontent.Contains("detained")) // TODO: remove string based logic
{
  streamWriter.WriteLine("released");
  statuscontent = "released";
}
else if (statuscontent.Contains("released"))
{
  streamWriter.WriteLine("detained");
  statuscontent = "detained";
}

thanks for the help

  • 1
    You could search/read up on globalizing & localizing applications, here's a starting point : https://learn.microsoft.com/en-us/dotnet/standard/globalization-localization/ or here https://www.infoworld.com/article/3037979/how-to-internationalize-your-application-in-net.html – PaulF Jul 31 '20 at 07:57
  • *"use enums"* - we can't help you with what is provided. See [mcve]. – Sinatr Jul 31 '20 at 08:01
  • It is better you use globalization and localization strategy, for this you need create resource files for each language you want to have in your application. Specifically if you are looking for localization with enums have a look this question https://stackoverflow.com/questions/17380900/enum-localization. you will see quite good answers. – nzrytmn Jul 31 '20 at 09:03

1 Answers1

0

You could use localized strings, meaning you add strings to resource files for each supported human language, and then set the culture to select the correct one. It looks like this answer is quite good: How to use localization in C#

Svein Terje Gaup
  • 1,424
  • 15
  • 29