Language files as embedded resources

Vote:
 

Hi!

I am trying to get the my Episerver plugin language file to work as an embedded resource but no success so far.
My plugin is placed in modules/_protected ths build action is set to Embedded Resource but when I copy everything to my test project I still get the "[Missing text...."].

Do I need to something else to get this to work?
Can I place the my xml file in modules/_protected and have Episerver to read my plugin file instead?

Which way is the right way to do it?

Thanks!

/Kristoffer

#171326
Nov 07, 2016 20:38
Vote:
 

Ok, so I skipped the embedded part and added the modules lang folder in an init module to get Episerver to read all the xml-files in that file.

public void Initialize(InitializationEngine context)
        {
                var localizationService = context.Locate.Advanced.GetInstance<LocalizationService>() as ProviderBasedLocalizationService;
            if (localizationService != null)
            {
                string langFolder = HttpContext.Current.Server.MapPath("~/modules/_protected/My.Plugin/lang");
                if (Directory.Exists(langFolder))
                {
                    var configValues = new NameValueCollection
                                           {
                                               {
                                                   FileXmlLocalizationProvider.PhysicalPathKey,
                                                   langFolder
                                               }
                                           };
                    var localizationProvider = new FileXmlLocalizationProvider();                    
                    localizationProvider.Initialize(Constants.ProviderName, configValues);                    
                    localizationService.Providers.Add(localizationProvider);
                }
            }
        }

And this works just fine and aloows me to easily add more language files if needed.

/Kristoffer

#171505
Nov 08, 2016 17:23
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.