StrataFrame Forum

Setting up Localization

http://forum.strataframe.net/Topic2203.aspx

By Andria Jensen - 8/16/2006

So, I went into the Localization & Messaging Editor, created a new project and added a text value for testing.  The key for the text value is "ParentTitle".  I then generated teh xml files, and verified they are going to the correct location.  In my InitApplication I have the following:

SetActiveLanguage("FactorSoft", 1033)
MessageXmlPath = CtlCommonPath &
"\Data"
MessageKeyType = Messaging.MessageKeyDataType.XML
MessageLocaleID = GetActiveLanguage(
"FactorSoft", UserName)

The necessary imports have been put in to make it more readable.  Since I only have one language set I shouldn't really need to do all of the Setting and Getting of ActiveLanguage, but I put it in there to make sure it is using the current LocaleID.  All of this executes fine, but when it goes to retrieve the text value of "ParentTitle" it says "The specified key [ParentTitle] was not found within the localization database."  Why is it looking in the database if I specified for it to look in the XML file?  What did I do wrong?

By Andria Jensen - 8/16/2006

Here is the Stack Trace:

8/16/2006 12:50:17 PM
Source: MicroFour StrataFrame Base
Message: The specified key [ParentTitle] was not found within the localization database.
Stack:    at MicroFour.StrataFrame.UI.Localization.RetrieveTextValue(String TextValueKey)
   at MicroFour.StrataFrame.UI.Localization.SetLocalizationOnControl(ILocalizable ControlToSet)
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

By Trent L. Taylor - 8/16/2006

First, you do not need to call SetActiveLanguage.  This is done in the GetActiveLanguage when settings the LocaleID.

Next, make sure that the XML files are are deployed to the [CtlCommonPath & "\Data"] location.. Do you have two backslashes?  Does the CtlCommanPath already have a backslash within in.  Next, manually open the XML file labeled "MessageItems_1033.xml" and see if the key PackageFile exists within the table.

FYI, whether it is coming from XML or the SQL Server database, it will still say "database." Smile

By Andria Jensen - 8/16/2006

I removed the call to SetActiveLanguage.  I also checked my debug to make certain, but the path to the xml files is C:\Production\Data\.  So, I am attaching the 2 xml files I have there.  I see the ParentTitle key, but I see nothing about PackageFile...where would this come from?
By Andria Jensen - 8/16/2006

Here are the XML files...I didn't see anything called MessageItems_Languages.xml  Only Message_Languages.xml and Messages_1033.xml.  Maybe this is the problem?
By Andria Jensen - 8/16/2006

Typo....I didn't see anything called MessageItems_1033.xml
By StrataFrame Team - 8/16/2006

Try this:

MessageXmlPath = CtlCommonPath & "\Data"
MessageKeyType = Messaging.MessageKeyDataType.XML
MessageLocaleID = 1033

and see what happens...

The SetActiveLanguage call isn't what actually sets the current langauge that the localization is going to use... I think it pulls up the editor so the end-user can choose the language, or something like that.  The current language is chosen by the LocaleID property, so set that, set the MessageKeyType, and the XmlPath, and it should work.

As for the XML files, they look fine, and the PackageFile Trent was talking about was probably a typo for "ParentTitle."

Also, the exception's message is the same for if you're using XML files or the database, so don't worry about it.  If you get that message, then the key couldn't be found for the language you're currently using.

By Andria Jensen - 8/18/2006

I put in that code and i'm still getting the same message.  It doesn't seem to be finding that ParentTitle field for some reason.  I'm going to keep plugging away at it, but if you have any ideas let me know.
By Andria Jensen - 8/21/2006

I'm still having no success getting this setup.  It appears that the XmlPath is right, and I'm doing the following:

Localization.MessageXmlPath = CtlCommonPath & "\Data"
Localization.MessageKeyType = Messaging.MessageKeyDataType.XML
Localization.MessageLocaleID = 1033
MsgBox(Localization.RetrieveTextValue("ParentTitle"))

I still get an error on the Retrieve saying it can't find ParentTitle as a key.  Is there possibly some step I'm leaving out when setting this up?  You guys have the XML files I've created and they seem to be right.  Is there anything else at all I can look at or try here?

By StrataFrame Team - 8/21/2006

Well, you have everything configured correctly... what is the stack trace for the exception that is being thrown when that key is not found in the files?
By Andria Jensen - 8/21/2006

8/21/2006 10:26:23 AM
Source: MicroFour StrataFrame Base
Message: The specified key [ParentTitle] was not found within the localization database.
Stack:    at MicroFour.StrataFrame.UI.Localization.RetrieveTextValue(String TextValueKey)
   at MicroFour.StrataFrame.UI.Localization.SetLocalizationOnControl(ILocalizable ControlToSet)
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
By StrataFrame Team - 8/21/2006

Nothing special there... do you have the source code downloaded?  I'm wondering if you could build it in debug and step through it to see where it's failing.
By Andria Jensen - 8/21/2006

I do, I'll try and do that today if I get some extra time.  Thanks.
By StrataFrame Team - 8/21/2006

OK, let me know what you find Smile
By Andria Jensen - 8/23/2006

Ok, who wants to hit themselves?  It didn't recognize the path because it assumes a backslash at the end.  I changed it to be Localization.MessageXmlPath = CtlCommonPath & "\Data\" and everything is working.  But on the bright side, I now have my StrataFrame code compiled in debug Wink
By Andria Jensen - 8/23/2006

Ok, jumped for joy too soon.  This did fix the localization thing, but after I compiled in debug mode I think I messed something up.  I think I had the new dll's from training on my machine, but I don't think I had the source code.  So, I think I compiled the wrong (old) source code and now I'm getting error messages all over the place.  Where can I get the right source code, or how can I fix this?
By Trent L. Taylor - 8/23/2006

Yes, you are correct.  You just need to load the install that you got from the training class back on your machine.  We have not released the source code for the new release yet.  Sorry. Ermm
By Andria Jensen - 8/23/2006

Guess I can't run in debug after all.  I just removed and reinstalled and it's fine now.  Just had a little panic attack, but all is well.  Thanks Smile
By Trent L. Taylor - 8/23/2006

Yup...sorry about that Blush  You will be able to run in debug mode in a couple of weeks when we publish the source code for the 1.5 update.