PHPå½éåããã°ã©ãã³ã° gettextã使ã£ãå½éå PHPã¯gettextã®ã¡ãã»ã¼ã¸ç®¡çããµãã¼ããã¦ããã®ã§ãã¦ã¼ã¶ã¼ãã±ã¼ã«ã«åºã¥ãã¦ãã©ãã«ãã¡ãã»ã¼ã¸ã®ããã¹ããåãæ¿ãããã¨ãã§ãã¾ãã 以ä¸ã¯ãWorld Wide Naviã®PHPã®æååå¤é¨åã®ãµã³ãã«ã使ã£ããåºæ¬çãªgettextã®ã¹ãããã§ãã ãã¼ã«ã©ã¤ãºããæååãgettexté¢æ°ã«é ç½® ãã¼ã«ã©ã¤ãºãããæååãgettexté¢æ°(æ®ã©ã®å ´åã'_()')å ã«é ç½®ãã¾ãã ãããã®æååã¯ãåå¤é¨ãªã½ã¼ã¹ãã¡ã¤ã«ã«ãã£ã¦ãã¼ã«ã©ã¤ãº(翻訳)ããã¾ãã echo "Hello from PHP!"; -> echo _("Hello from PHP!"); åæåã³ã¼ããè¨è¿° ã¦ã¼ã¶ã¼ãã±ã¼ã«(è¨èªã¨å°å)ãé©ç¨ãããªã½ã¼ã¹ã®ååã¨ãã¹ãgettextã®ä»çµã¿ã«æãã¾ãã index.php (ã¾ãã¯ä»
ã¯ãã㫠便å©ãª GUI ãã¼ã«ãã¡ æ¨ä»ã§ã¯ã翻訳ãããã«ããGUI ãªãã¼ã«ããweb ãã¼ã¹ã®ãã¬ã¼ã ã¯ã¼ã¯ãªããããããããã£ãããã¦ãä¸æãããã¨ãã³ãã³ãã©ã¤ã³ã使ããªãã¦ã翻訳ä½æ¥ãã§ããããã¾ãã ã¹ã¿ã³ãã¢ãã¼ã³ã®ãã¼ã«ã¨ãã¦ã¯ããã¨ãã° po ã¨ãã£ã¿ã¼ã® Poedit ãããã¾ãããã㯠po ã ãã§ãªã mo ãã¡ã¤ã«ãæ¸ãåºããã¨ãã§ãã¾ããKDE ã® Lokalize ã¯ãããã¸ã§ã¯ã管çã«ä½¿ããã¨ãæ³å®ãã¦ããããã£ã¨ããããªæ©è½ãã¤ãã¦ãã¾ãã web ãã¼ã¹ã®ã·ã¹ãã ã¨ãã¦ã¯ã3æ¥ç®ã§ç´¹ä»ããã¦ãã pootle ã6æ¥ç®ã§ç´¹ä»ããã¦ãã Transifexã10æ¥ç®ã§ç´¹ä»ããã¦ãã Translation wiki ããLaunchpad ãªã©ãããã¾ãã ä¸ç¿»è¨³è ã¨ãã¦ãªããã³ãã³ãã©ã¤ã³ãä¸å使ããã«ä½æ¥ãããã¨ã¯ãµã¤ãã«ãããã¨ã§ãããã ã³ãã³ã
翻訳ãã¡ã¤ã«ä½æã® 3 ã¹ããã å æ¥ããã©ã°ã¤ã³ã¨ãã¼ãã®ãã¼ã«ã©ã¤ãºã«ã¤ãã¦ä¸»ã«ãã©ã°ã¤ã³ããã¼ãã®éçºè ã®è¦ç¹ã«ç«ã£ã¦æ¸ãã¾ããããä»åº¦ã¯ç¿»è¨³ããã人ã®ç«å ´ã§è¦ã¦ã¿ããã¨æãã¾ãã gettext ã®ç¿»è¨³ãã¡ã¤ã«ä½æããµãã¼ããããã¼ã«ã¯ããã¤ãããããã§ãããWindows ã§ã¯ poEdit ã使ãã¾ããpoEdit ã®ç¾æç¹ã§ã®ææ°ãã¼ã¸ã§ã³ã¯ 1.3.4 ã§ãã poEdit ã使ã£ã翻訳ãã¡ã¤ã«ä½æä½æ¥ã®æµãã¯æ¬¡ã®å段éã«åããã¾ãã ã½ã¼ã¹ã³ã¼ããã翻訳対象ã®ããã¹ããèªåæç²ã.po ãã¡ã¤ã«ãçæããã 翻訳対象ã¨ãªãããã¹ã㯠__() 㨠_e() ã®ã¨ãããªã®ã§ãpoEdit ã¯ã½ã¼ã¹ãã¡ã¤ã«ããµã¼ããã¦èªåã§åéãã¦ããã¾ããçæããã .po ãã¡ã¤ã«ã¯ããã¹ããã©ã¼ãããã®ãã¡ã¤ã«ã§ã次ã®ç¿»è¨³ä½æ¥ã§ç·¨éã«ä½¿ããã¾ãã .po ãã¡ã¤ã«ãç·¨éã翻訳ä½æ¥ãè¡ãª
extentionã®gettextãå©ç¨å¯è½ã«ãã php_gettext.dllã®ã³ã¡ã³ãã¢ã¦ãã¯ããã¨ã--with-gettextã§ã³ã³ãã¤ã«ããã¨ã gettextã®moãã¡ã¤ã«ãä¸è¨ã«é ç½® ããã¸ã§ã¯ããã£ã¬ã¯ããª/locale/ja/LC_MESSAGES/{APPID}.mo APPIDã¯å¤§æå ãã³ãã¬ã¼ãã®å½éå Smartyã®modifierãã©ã°ã¤ã³ãå©ç¨ãã {"message"|i18n} ã¢ã¯ã·ã§ã³ãã©ã¼ã ã®å½éå {APPID}_ViewClassã®getFormNameã¡ã½ããããªã¼ãã¼ã©ã¤ã function getFormName($name, $action, $params) { $af =& $this->_getHelperActionForm($action, $name); if ($af === null) { return $name;
å°¾è¤æ£äººã§ãã ã¦ãã¦ã§ã¯æµ·å¤å ¬éãåæã«äºæ¥ãå±éãã¦ããã®ã§ãã»ã¼ä¾å¤ãªãããã°ã©ã ã¯å½éåããã¦ãã¾ããå æ¥å ¬éãã Melovie ãã¡ããã¨å½éåããã¦ãã¦ããã©ã¦ã¶ã®è¨èªã®è¨å®ãå¤ããã¨è±èªã§è¡¨ç¤ºããã¾ãã æè¿ãã³ãã¬ã¼ãã¨ã³ã¸ã³ã§ Smarty ã使ãå§ããã®ã§ããããã®ã¾ã¾ã§ã¯ gettext ã¨ãã¾ãçµã¿åããããã¨ãã§ããªãã®ã§ãã¦ãã¦ã§ã¯ç¬èªã®ä»çµã¿ãå ¥ãã¦ãã¾ããæ¥æ¬èªã 㨠Smarty 㧠gettext ãã£ã¦ãæ å ±ãå ¨ç¶ãªãã®ã§ãã¦ãã¦ã§ãã£ã¦ããæ¹æ³ãç´¹ä»ãããã¨æãã¾ãã Smarty 㧠gettext ã使ãã¨ãã®ä¸çªã®åé¡ç¹ã¯ã¡ãã»ã¼ã¸ã®æ½åºã§ããSmarty 㯠PHP ã¨ã¯ææ³ãç°ãªãã®ã§ããã®ã¾ã¾ã§ã¯ xgettext ã使ã£ã¦ã¡ãã»ã¼ã¸ãæ½åºãããã¨ãã§ãã¾ãããPHP å´ã§å ¨ã¦ã®ã¡ãã»ã¼ã¸ãå¤æ°ã«ä»£å ¥ããã¨ããã®ãä¸ã¤ã®æ¹æ³ã§ããããã¯ã
ã¸ã¥ã³ã¤ã§ãã 5åã§ããã PHP ã§æ¸ããã Web ãµã¼ãã¹ã®å½éå ã«ç¶ã㦠gettext ã®è©±ã 以ä¸ãè±èªã§ãHelloããæ¥æ¬èªã§ãããã«ã¡ã¯ãã¨è¡¨ç¤ºããç°¡åãªããã°ã©ã hello.php ã§ãã <?php $language = 'en'; if (ereg('ja', $_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $language = 'ja_JP'; } // Set locale and default domain. putenv("LANG=$language"); setlocale(LC_ALL, $language); $domain = 'messages'; bindtextdomain($domain, "/var/www/html/locale"); textdomain($domain); // Output e
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}