0

I've created a DLL which has functional uses, but it also has resources inside of it, which it uses itself, but it needs to be translated for different languages. The translation itself is not the issue, rather how these translations can be implemented.

I've had a look around, and the two main options I could find for DLL translation practices is:

  • Provide a different DLL for each language, then in the main project use the correct DLL for the current culture.
  • Have translations inside the DLL where the DLL detects the current culture through the line below (haven't tested if that line works yet), and then it uses the translations inside itself to provide the correct translated output.

    Assembly.GetExecutingAssembly().AssemblyName.CultureInfo

So my questions are which method of those is the best practice (if any!), and do you have and pointers on how best to do translations inside the DLL itself?

AidanH
  • 502
  • 5
  • 24
  • https://learn.microsoft.com/en-us/dotnet/standard/globalization-localization/ - You don't create DLLs you create .resx files. – Matthew Watson Apr 19 '18 at 08:23
  • @Matthew Watson I don't think I explained it clearly enough, it's not the project that needs translating, its the DLL itself. The DLL is an exporting service that creates files with text inside of them, the text needs to be translated in the module. – AidanH Apr 19 '18 at 08:26
  • Could the downvoter kindly explain the reason so I can improve my question? – AidanH Apr 19 '18 at 08:28
  • Well I think you should be putting the translations into a separate DLL as per the Microsoft instructions. (I didn't downvote btw) – Matthew Watson Apr 19 '18 at 09:05
  • @MatthewWatson That's interesting, since I've done some more research, and this seems to be one of the most used localization techniques: https://stackoverflow.com/questions/1142802/how-to-use-localization-in-c-sharp I'll look into the Microsoft instructions still though - thanks. – AidanH Apr 19 '18 at 09:09
  • If you do put stuff into the resx file, that puts the strings into the main DLL file - but then when you want to add localisations you will add more resx files with special names, and THEY will create an additional satellite resource DLL for each one. (That's what I meant by putting the translations into a separate DLL.) – Matthew Watson Apr 19 '18 at 09:38
  • @MatthewWatson I was just about to correct myself but you beat me to it! Thanks for the help, it seems to be working now – AidanH Apr 19 '18 at 09:40

1 Answers1

1

It turned out to be very simple:

  • In the DLL, add a copy of the main resource file, but with the ISO prefix, e.g. 'Resource.de.resx', and translate the value text inside.

This created multiple DLLs in sub-folders and such, just add references to them and the DLL will automatically detect the current UI culture and therefore use the correct resx with translations (if available).

Thanks @MatthewWatson for the help!

AidanH
  • 502
  • 5
  • 24