Embedded language file for Add-on

Vote:
 

Hi,

I'm currently working on an add-on for EPiServer CMS 7, and I've created a NuGet package that works fine except one thing - the language file.

For previous versions of CMS, we always had the language file in the lang folder in the site root. However, because of the new module architecture and since the language folder path is now configurable, I thought that it would be better to embed the language file instead.

I've searched high and low for an article explaining how to do that, but haven't found anything. So, what is the best way to embed a language file into the dll? Also, do I have to have separate files for each language, or can they be in the same file?

Thanks,

William

#65277
Jan 24, 2013 14:36
Vote:
 

In our Add-On, we have language files in lang folder in the project, one for English and the other for Swedish.

This is how one looks like, for example:

<?xml version="1.0" encoding="utf-8" ?>
<languages>
  <language name="svenska" id="sv">
    <global>
      <filter>Filtrera</filter>
      <edit>Ändra</edit>
...

In Properties, Build action is set to Embedded Resources and  Copy to Output Directory is set to Do not copy.

If this means anything, they are named as Mogul_SV.xml, but I don't think it does.

 

#65279
Jan 24, 2013 14:49
Vote:
 

Embedded language files is the primary and recommended localization model for add-ons. Add xml file with translations in your project, right-clieck on file in solution explorer and select properties. Set Build Action to Embedded Resource option in file property panel and rebuild the project.

You can have translations for all languages in one file or you can create one file per language, it's up to you. As for me, language files are easier to maintain when they are separated by the language.

You can also use standard resource files, if you want.

#65280
Jan 24, 2013 14:55
Vote:
 

Hi!

Do I have to do anything more than just set build action to Embedded?

I have set the the action but when I copy my plugin dll to my test project the @Html.Translate() gives me "Missing text..."
Should @Html.Translate() work with the embedded file out of the box or do I have do access the file in some other way?

Thanks!

/Kristoffer

#171283
Nov 04, 2016 12:53
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.