php 使用gettext实现国际化问题! 用过的进来讨论一下撒~~
我的环境:ubuntu server +xampp 套件
php代码中的输出是使用简体中文来输出的,现在 要将简体中文的输出转换成英文,和繁体中文。
使用gettext 来做。
现象 : 无法转换!
但是, 如果吧代码中得中文换成英文字符,然后在 .po文件中更新一下,再生成.mo文件后,则能够正常转换!
也就是说 当po文件中的需要转换的字符串为中文的时候 则不能转!
即 中文 --》 其他语言 ,不成功!
英文 --》 其他语言 ,则能够成功!!
请大家来讨论下这是为什么?!
------解决方案--------------------
下载地址:
http://sourceforge.net/projects/gnuwin32/files/gettext/0.14.4/gettext-0.14.4-src.zip/download
- PHP code
第一步:撰写PHP程序 <?php putenv("LANG=zh_CN"); setlocale(LC_ALL, "zh_CN"); bindtextdomain("test", "./locale"); textdomain("test"); echo gettext("Hello!"); echo gettext("World!"); echo gettext("Hello World!"); ?> 第二步: xgettext.exe -d test -L PHP --from-code=utf-8 index.php 第三步: 修改test.po为: #: ../index.php:8 msgid "Hello!" msgstr "你好!" #: ../index.php:9 msgid "World!" msgstr "世界!" #: ../index.php:10 msgid "Hello World!" msgstr "你好,世界!" 第四步: msgfmt -o zh_CN/test.mo zh_CN/test.po 生成test.mo文件 第五步: 创建locale\zh_CN\LC_MESSAGES目录,将test.mo放入该目录中 第六步: 重启apache,访问index.php即可看到效果 <br><font color="#e78608">------解决方案--------------------</font><br> 编码用utf-8试试 <div class="clear"> </div>

LeicareleasedtheLeicaLuxcameraappfortheAppleiPhoneafewdaysago.However,theappwasnotdevelopedbyLeica,butbyFjorden.ThecompanyhasbeenknownprimarilyforitscameragripsfortheiPhoneandwasacquiredbyLeicainDecember2023.Fo

SincethedemiseofLogitech'spopularHarmonyremotecontrols,themarketforhigh-qualityuniversalremotecontrolshasbeenfragmentedatbest.UnfoldedCircleaimstoavoidthefateoftheHarmonyUltimatebyeliminatinganyserverobligationsorsubs

WhiletheLightPhone2from2018wasstillequippedwithaneconomicale-inkdisplay,theLightPhone3usesanOLEDdisplaythatcanonlydisplaygrayscale.Thereasonfortheswitchtothe3.92-inchOLEDpanelwithitsresolutionof1,240x1,080isth

TheJabraEliteserieshascometoanend,withGNCEOPeterKarlstromerannouncingthediscontinuationofthewirelessearbudswithinthelineupinapressrelease.Petersaysthatthechangingmarketdynamicsandhowchallengingithasbecometogetas

Audio-TechnicahasunveiledtheATH-S300BTwirelessheadphoneswithhear-throughnoise-cancellation,multipointpairing,and90hoursofbatterylife.Thenoise-cancellingfeaturehasthreemodes:off,on,andhear-through,whereambientsoundscanbehea

Backin2022,whenPCIe7.0wasstartingtotakeshapeasafuturestandard,PCIe5.0wasjusthittingtheservermarketsandtheprospectofseeingPCIe6.0devicesavailableanytimesoon,letalonePCIe7.0ones,wasquitefar-fetched.CurrentlyPCIe5

HisensehaslaunchedtheStarlightS1ProLaserTVinChina.TheproductwasteasedinaWeibopostearlierthismonthandwasunveiledatthe2024HisenseTVNewProductLaunchConferenceeventonJune12th.TheStarlightS1Proisa4KlaserTVinfours

TheHYgreenGOMOWrobotlawnmowerisduetolaunchinGermanysoonandcouldarriveinothercountriesinthefuture.Theproductwillbeshownatspoga+gafa2024inColognefromJune16thto18th,withtheCalifornia-basedcompanylocatedatHall5.1St


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

SublimeText3漢化版
中文版,非常好用

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

Dreamweaver CS6
視覺化網頁開發工具

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中