Reputation: 6353
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 to concatenate a ':' onto the end of the localized text.
Anyone know how to do it?
TIA, James
Upvotes: 3
Views: 3242
Reputation: 832
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.
Upvotes: 0
Reputation: 350
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.
Upvotes: 0
Reputation: 4052
You could also append the colon using CSS if your labels are positioned appropriately.
label:after
{
content: ':';
}
Upvotes: 1
Reputation: 8914
I've always put the colon outside the label.
<asp:Label ID="RoleTypeLabel" runat="server" Text="<%$ Resources: GS3,
RoleTypeLabel %> />:
Upvotes: 4