Solved

C# export object to javascript, translate page controls

Posted on 2014-09-27
1
229 Views
Last Modified: 2014-10-18
Our internal site has about 200 pages on it and each page has anywhere from 20-100 labels(controls) with titles that need translating.

We don’t do any controls in .NET ie. No serve side or runat.

We currently use Resource files with our 5 different languages and pivot off the users language to display the appropriate text/translation.

Looks something like this.


m.LangOutControl = GetLanguage();

    private string GetLanguage()
    {
        return string.Format("{0},{1},{2},{3},{4}",
              InnUtil.GetResourceLabel("plnCopytoNextPeriod", InnEnum.ResourceFile.App2),
              InnUtil.GetResourceLabel("labStrategy", InnEnum.ResourceFile.Common),
              InnUtil.GetResourceLabel("labAction", InnEnum.ResourceFile.Common),
              InnUtil.GetResourceLabel("labMeasure", InnEnum.ResourceFile.Common),
              InnUtil.GetResourceLabel("labIDP", InnEnum.ResourceFile.Common)
             );
    }

Open in new window



}

This returns a string to a JS function on the master page.

    <script type="text/javascript">
        function GetLangControl() { return '<%= LangOutControl %>'; }
    </script>

Open in new window


Then we put it into an object in JS and load populate the TEXT/HTML.

So I want to move this away from resource files and into our DB, create a tool that the owners of the Applications can manage the text/labels etc. by the appropriate language.

First question: Anyone have a different approach that might work for us.

Second question: How do I make my return an object so I don’t have to rely on position. Ie. From C# my return is this:

{
Lbl: “First Label”,
Lbl2: “Second label”
}

Open in new window

0
Comment
Question by:skillilea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40348152
I believe this page answer your question : http://msdn.microsoft.com/en-us/library/bb412179(v=vs.110).aspx
So mainly the goal to create a DataContract which define your object with DataMember (which can be based on other DataContract) and use DataContractJsonSerializer to create this Javascript object
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Universal App 22 63
EF5: Update Model from Database not working 3 83
What!!!??? 5 62
Web Site Administration Tool - Security Questions 2 39
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question