Whim, suddenly want to study PHP multi-language.
Look at the company's projects and WordPress are used by the GetText () to multi-lingual.
Then open the PHP manual to copy the following paragraph
<?PHP//Set language to Germanputenv(' Lc_all=de_de ');setlocale(Lc_all, ' De_de '); //specify location of translation tablesBindtextdomain ("Myphpapp", "./locale"); //Choose DomainTextdomain ("Myphpapp"); //translation is looking for in./locale/de_de/lc_messages/myphpapp.mo Now//Print a test messageEchoGetText ("Welcome to My PHP application"); //Or Use the alias _ () for GetText ()Echo_ ("A Nice Day");?>
And then I got a poedit on the net to compile Mo files.
The result is a lazy process, which changes the MO file name to test and assigns the Textdomin value in the code to test.
Oh..... It turned out to be tragic.
GetText () function kill translation.
And then all sorts of attempts. The following are unscientific experimental processes (function requirements Textdomain values need to be consistent with Mo filenames)
Textdomain value |
MO file Name |
GetText Running Status |
Comments |
He |
He.mo |
Normal |
|
Heh |
Heh.mo |
Normal |
|
Test |
Test.mo |
Flutter Street |
|
Zh_cn |
Zh_cn.mo |
Flutter Street |
|
Zh_cn |
Zh__cn.mo |
Normal |
The middle is two underline |
Hehe |
Hehe.mo |
Flutter Street |
|
Heheh |
Heheh.mo |
Normal |
Normal starting from the length of the stored character greater than or equal to 5 o'clock |
Hehehehe |
Hehehehe.mo |
Normal |
|
Heheheheh |
Heheheheh.mo |
Normal |
|
Hehehehehe |
Hehehehehe.mo |
Normal |
|
Myphpapp |
Myphpapp.mo |
Normal |
|
Myphpapp |
Myphpapp.mo |
Normal |
|
Translations |
Translations.mo |
Normal |
|
Conclusion: GetText translation function corresponds to the value of Textdomain is equal to 4 characters (or add an underscore), there will be a bug read error (Note: When the Textdomain value and Mo file name does not correspond, the system will try to look in the cache, if there is a cache, The GetText can work properly.
)
PHP GetText Use method attach strange bug One