Eddy51 Posted February 16, 2009 Share Posted February 16, 2009 I am trying to convert a script which I originally wrote in English to work in another languages. I had a request to write the script in Romanian so that's what I have been trying to do. Your help would be greatly appreciated I'm really stuck with this one. I bet the solution is quite simple. This is a very strange problem which I just don't quite understand and has got me really stumped. My script works fine with the English language file but the Romanian one doesn't work. The strange thing is; [*]The Romanian text "Nu ai nimerit" is matched but the others are not [*]If i write $text['duel_pattern']="/(Nimerit: (Braţul drept|Umărul drept|Braţul stâng)\s-\s\d{1,} Puncte de viaţă)|(Nu ai nimerit)/"; into my main script file all the Romanian text is matched correctly [*]The English file works with no problems The only thing I can think of it's something to do with the different characters used in the Romanian text. Here is my script: en.php <?php // Declare all text strings, // in English. $GLOBALS['text'] = array ('duel_pattern' => "/(Strike:\s(Right arm|Right shoulder|Left arm|Left shoulder|Head)\s-\s\d{1,3}\sHP)|(No hit)|(Total health points\s-\s\d{1,3}\sHP)/"); ?> ro.php <?php // Declare all text strings, // in Romania. $GLOBALS['text'] = array ('duel_pattern' => "/(Nimerit: (Braţul drept|Umărul drept|Braţul stâng)\s-\s\d{1,} Puncte de viaţă)|(Nu ai nimerit)/"); ?> MainScript.php <?PHP // Now include the appropriate language file: require_once "./lang/{$lang}.php"; //Parse hits in to an array preg_match_all($text['duel_pattern'],$str,$hits); ?> Quote Link to comment https://forums.phpfreaks.com/topic/145361-solved-preg-different-language-not-working/ Share on other sites More sharing options...
Eddy51 Posted February 17, 2009 Author Share Posted February 17, 2009 SOLVED IT I noticed when that when I saved my ro.php file some of the special characters didn't save correctly. I thought this was a bit strange so tried saving them on my mainscript.php file and they saved correctly. Hmm, well I thought what could be causing this so checked the page properties(Dreamweaver) and seen that the mainscript.php file was encoded in UTF-8 while the ro.php file is encoded in Western European. I changed the encoding on the ro.php page to UTF-8 and problem solved . All the special characters saved correctly and the preg worked how it was meant to. Well like I first said it was to do with the different characters but was to do with there encoding. Quote Link to comment https://forums.phpfreaks.com/topic/145361-solved-preg-different-language-not-working/#findComment-764582 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.