skillilea
asked on
C# export object to javascript, translate page controls
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.
}
This returns a string to a JS function on the master page.
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:
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)
);
}
}
This returns a string to a JS function on the master page.
<script type="text/javascript">
function GetLangControl() { return '<%= LangOutControl %>'; }
</script>
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”
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.