开发者

Concatenating text in an ASP.NET localized label

Trying to localize text in ASP.NET labels... want to add a ':' after the localized text. I could just add the ':' to the localized text in the resource file, but that seems silly... there should be an easy way to do this.

<asp:Label id="RoleTypeLabel" runat="server" Text='<%$ Resources: GS3, RoleTypeLabel %>:' AssociatedControlID="RoleTypeDropDown"></asp:Label>

(note the ':' at the end of Text='...')

Of course, this doesn't work... and neither does anything I can think of t开发者_StackOverflowo concatenate a ':' onto the end of the localized text.

Anyone know how to do it?

TIA, James


I've always put the colon outside the label.

<asp:Label ID="RoleTypeLabel" runat="server" Text="<%$ Resources: GS3, 
RoleTypeLabel %> />:


why dont you put ':' into the resource file?


You could also append the colon using CSS if your labels are positioned appropriately.

label:after
{
    content: ':';
}


Just ran into a similar situation as I went back and localized one of our apps. Ended up using a Literal control inside the Label:

<asp:Label AssociatedControlID="txt" CssClass="class" ID="lbl" runat="server">
    * <asp:Literal runat="server" Text="<%$ Resources:Words, labelText %>" />:
</asp:Label>

We were using some CSS to right align form labels with a fixed width so any text outside of the label actually broke our pages. The accepted answer is most straight forward, but might not work in all situations.


You should include the colon as part of the string that you mean to translate. See #3 in this 12 Commandments of Software Localization article, which explains that punctuation often needs to be translated. For example, French adds a space before the colon, and languages like Arminian or Greek may use a different symbol in the colon's place.

As for reusing terms, consider that "Due:" and "Due" are different enough linguistically that you're better of translating them individually.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜