views:

875

answers:

3

In my application I have paragraphs with mixed static text and HTML formatting and links. I'm looking for a good localization solution that keeps resources decoupled from markup. Let's say we have the following paragraph:

<p>Let's have a <a href="someURL">cup of coffee</a> and get <b>energized</b>.</p>

Using the standard resx solution forces me to embed the HTML markup and the link destinations in the resx string. This is bad because it couples markup/CSS/app structure with resources.

The next best thing is to split the paragraph such that localized content never contains markup. In the above example I would have 4 para fragments: 1) "Let's have a" as plain text 2) "cup of coffee" as a link 3) "and get" as plain text 4) "energized" as bold text

The problem with this solution is that fragmentation makes maintenace of resources a complete nightmare plus it forces a certain order of the paragraph fragments which might not fit the grammar of all cultures. For instance, in the translated language the proper translation might be

<p>Let's get <b>energized</b> with a <a href="someURL">cup of coffee</a>.</p>

I don't think I can quite get away with not embedding markup into resources and that might not be a huge deal. Using proper markup/CSS (span, div, id, class) I can create abstractions that would lessen the impact of coupling.

What do I do about the link URLs though? Thanks,

Stefan

+2  A: 

Don't view the HTML as "formatting", but as structure, and save all of it to a resource data store (such as resx, or a database, or xml files or something). Then you can stop worrying about little bits of text inside a paragraph. Instead, you'll have some reference to a resource called "paragraph_energized_with_coffee" or something, per locale, and whatever software you use to edit the resources will determine what flexibility editors have in structuring the html inside each resource.

Rahul
If I do that and then a link URL changes I need to go through each localized version of "paragraph_energized_with_coffee" and update the URL. I'd like a solution that doesn't force me to do that.
stefann
FYI, the para text is not some blog-like content, but rather functional notes like you can see right here (just below) where it says "Not the answer you're looking for? Browse other questions tagged <a>some tag</a> or <a>ask your own question</a>". Thanks!
stefann
Your resource editor (that is used to edit the locale html) could be aware of the structure of your app and offer a hyperlink tool that allows editors to select another resource to link to. That way you keep hyperlinks centralized but still use html for structure.
Rahul
It's worth keeping in mind that some languages will require different HTML markup due to differences in the language itself. For example a Welsh translation would likely be much longer than the English original. Some cultures have different rules for text flow (i.e. Arabic right-to-left) which could have an affect on the markup required :)
Ryan Barrett
A: 

I'm on Rahuls side - I would consider the html/css of content...just that...content.

The main reason is because when you want to do bulk content updates to a website, you will just have to copy paste from provided html/css into the resx files. It's also a lot quicker to do the orginal templating from html/css into asp.net.

There are also some refractor tools that have "export to resx file" options when content is selected that may speed things up.

Thanks!

scottschulthess
A: 

I came across this googling the exact same problem. It is intentional, since if you send the resources file to a translator he/she might not understand HTML and could damage your code. I don't like this either.

Yes, precisely! That's the reason breaking up the paragraph is bad too because you have to force the translator to understand why the heck the now have to translate all these separate pieces. I'm still thinking and will get back on the thread if I have better ideas.
stefann