I'm working on a site that will be delivered in at least English and Spanish (and possibly French, German et. al). I've reached a bit of a conundrum when it comes to displaying in-language prompts that are fairly extensive -- especially when I want to a) merge db data into the text and b) when I want to use HTML markup.
For example, at registration I want to send a welcome-to-our-site email that has HTML markup. In English, this email is likely to look something like this:
Code:
<p><b>Welcome to SiteX</b><.p>
<p>Dear <?php echo $username; ?>,</p>
<p>We are proud to welcome you to our awesome new website blah blah blah blah blah amazing features blah blah blah.</p>
<p>If you ever want to change your preferences please visit <a href="<?php echo $preference_url; ?>">The Preferences Control Panel</a>.</p>
This is obviously in English but I will want one in Spanish too. My instinct would be to create a separate view for the Spanish version of this file, but view loading is not language-aware like the language files are. If I were to do this in some CodeIgniter-orthodox way using language files, I might need to load each paragraph separate from a language file and merge $username and $preference_url into the resulting in-language strings and then merge this, in turn, into my view which would probably be JUST HTML markup like this:
Code:
<p><b><?php echo $welcome_message; ?></b><.p>
<p><?php echo $username_salutation; ?></p>
<p><?php echo $paragraph_1; ?></p>
<p><?php echo $paragraph_2a; ?><a href="<?php echo $preference_url; ?>"><?php echo $paragraph_2b; ?></a>.</p>
Or something like that. Notice how crazy that last line gets if we avoid HTML markup in our language strings.
Does anyone have a way of handling language localization+html markup+merged data all at the same time?