0

Spending hours on this. Thinking my thought process might be off..

I wanted to create one point of entry for language translation across different libraries and applications.

What I did was the following:

Created New Class Library Project called Translations At Root Level Added New Item - MyStrings.en-US.resx file Populated resx file resx - Access Modifier set to Public

At Root Level of Translations Project Added New Item Class - Translator Added Property

public class Translator
    {
        private ResourceManager _translationManager;
        public ResourceManager TranslationManager
        {
            get
            {
                if (_translationManager == null)
                {
                    _translationManager = new ResourceManager("MyStrings", this.GetType().Assembly);
                }
                return _translationManager;
            }
        }

    }

In WebSite (not web project but website) Added Reference to Translations Project In the code behind declared

        private Translator _translate;
        public Translator Translate
        {
            get
            {
                if (_translate == null)
                {
                    _translate = new Translator();
                }
                return _translate;
            }
        }

then in a LINQ statement

Title = TranslationManager.GetString(appsAvailable.Value.ResourceKey, CurrentCulture)

ResourceKey does have a value
CurrentCulture = en-US

And I am getting this error

Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "MyStrings.resources" was correctly embedded or linked into assembly "Translations" at compile time, or that all the satellite assemblies required are loadable and fully signed.

When I look at my bin/obj/debug folder I am seeing this Translations.MyStrings.en-US.resources

which is not the name it is looking for. I have tried to modify the "basename" for the manager from "MyStrings" to 'Translations.MyStrings" but I get a similar error stating "Translations.MyStrings.resources" can't be found. I have also tried just saying okay forget the culture right now let's access it "Translations.MyStrings.en-US" as the base name. and it says it still can not find it.

Any ideas of where I am going wrong? I am thinking it needs to be copied somewhere so the software finds it but don't know where it goes? Or am I trying to do something that it is not meant to do?

Your help is greatly appreciated!

1 Answers1

0

Just download MAT (Multilingual App Toolkit) for Visual Studio. https://marketplace.visualstudio.com/items?itemName=MultilingualAppToolkit.MultilingualAppToolkit-18308

This is the way to go to translate and maintain your projects in Visual Studio ;-) https://blogs.msdn.microsoft.com/matdev/

juFo
  • 17,849
  • 10
  • 105
  • 142