Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

How do I use the LocalizationService method GetString()?


Lets say I have something like this in a language file,

<pagetype name="MyPage">
        <name>My page</name>
        <description>My very special page.</description>

        <property name="MyProperty">
          <caption>My property caption</caption>
          <help>My property help text.</help>



How do I get the caption and help from the pagetype property using the LocalizationService?

Dec 02, 2013 22:39


It's xpath, so I guess something like this should work:

<%= Translate("/pagetype[name=MyPage]/property[name=MyProperty]/caption") %>


Dec 02, 2013 23:49

Thanks Johan,

but that displays [Missing text '/pagetype[name=MyPage]/property[name=MyProperty]/caption' for 'Swedish'] even though I have entered it in swedish.



Dec 03, 2013 9:55

It should be like this:



Dec 03, 2013 12:16

Thanks Sergii,

that isn't working either though. =(

[Missing text '/pagetype[@name='MyPage']/property[@name='MyProperty']/caption' for 'Swedish']

Could it be that there needs to be something before "/pagetype..." to specify the path to the language file?

Dec 03, 2013 12:36

Yes, you have to specify the whole path. We could only guess the parts you posted here ;)

Dec 03, 2013 16:06

But that doesn't seem right? What if I have a language file for each language, I don't think I should need to check which language is currently used and then write the path to that specific file, right?

Dec 04, 2013 12:06

You don't need to specify the language part,  "/languages/language/", but everything after that.

Dec 04, 2013 15:02

That wasn't what I meant.

Lets say I have two files in my languages directory, Translations_en.xml, Translations_sv.xml.

When we're talking about specifying the whole path, does that include the file name? Do I need to check which language is currently in use and specify the correct language file?

Perhaps an example would clear out any confusions? =)

Dec 04, 2013 15:06

When we said the path, we meant the path within the xml file. You can read about it here

But you can leave out the first two nodes, "/languages/language/", because EPi selects those automatically.

Dec 04, 2013 15:32

Yeah that's how I have been doing it.

I just saw that I left out a piece from the path.


should be




Edited, Dec 04, 2013 15:38
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.
* 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.