PHP - bindtextdomain停止在本地化网站的某些页面上工作

I am hoping someone can help me with this issue. My website is localised into German, French, Spanish and English. Everything seems to work correctly but during testing and often sporadic, the localised text does not appear and except the string codes appear. The variable $language is been set correctly as the images are language specific and they are always displaying.

The code I am using is as follows:

// I18N support information here
putenv("LANG=" . $language); 
setlocale(LC_ALL, $language);

// Set the text domain as "messages"
$domain = "messages";
bindtextdomain($domain, "./locale"); 
bind_textdomain_codeset($domain, 'UTF-8');

textdomain($domain);

The one thing I do seem to notices is this issue only occurs in pages of format: http://example.com/product/product_name.php It always works in pages of format http://example.com/page.php

Can anyone help or even give me details on how I could debug

You will need to ensure that your path to bindtextdomain is correct. I would suggest this in your bootstrap file:

define('ROOT_PATH', dirname(__FILE__));

and then in your script

bindtextdomain($domain, ROOT_PATH . '/locale');

This way if you get into a subfolder such as product/product_name.php bindtextdomain will not try to find the locale folder in the product folder.