Jump to content

[SOLVED] Languages and language keys


rossmurphy

Recommended Posts

Hi all,

 

I have a language file with language keys that look something like this..

 

$lang["label.gameid"] = "Juego núm.";
$lang["title.video.poker"] = "Video póker";

 

I use the htmlentities(); function to get them and echo them to the html page.

 

I want to be able to use HTML in the keys though. Something like this..

 

$lang["title.video.poker"] = "<span class="bold">Video póker</span>";

 

Then i would use html_entity_decode(). But this doesn't work for the special characters. How can i go about doing this?

 

Would i have to have my language keys like this:

 

$lang["title.video.poker"] = "<span class="bold">Video póker</span>";

 

Already converted to html characters or is there another way to do this?

 

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/180301-solved-languages-and-language-keys/
Share on other sites

Thanks for your reply, i had already tried that, sorry i didn't mention. I found a solution though.

 

Not sure what characters ranges it will work for, but seems good so far, i will keep it updated.

 

<?php

$translation = get_html_translation_table(HTML_ENTITIES);
$str = "Hallo & <span class=\"bold\">Frau</span> & Krämer";
$encoded = strtr($str, $translation );

echo htmlspecialchars_decode($encoded);

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.