Php uses gettext for internationalization! I used to come in and discuss it ~

Source: Internet
Author: User
Php uses gettext for internationalization! I used to come in and discuss it ~~ My Environment: ubuntuserver + xampp php code is output in simplified Chinese. now I want to convert the output of simplified Chinese to English or traditional Chinese. Use gettext. Php uses gettext for internationalization! I used to come in and discuss it ~~
My Environment: ubuntu server + xampp suite

The output in php code is output in simplified Chinese. now we need to convert the output in simplified Chinese to English or traditional Chinese.
Use gettext.

Symptom: conversion fails!
However, if you replace Chinese with English characters in the code, update it in the. po file, and generate the. mo file, the conversion will be normal!


That is to say, when the string to be converted in the po file is Chinese, it cannot be converted!

That is, Chinese -- other languages, not successful!
English -- other languages, you can succeed !!


Let's discuss why ?!



------ Solution --------------------
:
Http://sourceforge.net/projects/gnuwin32/files/gettext/0.14.4/gettext-0.14.4-src.zip/download
PHP code
Step 1: Write a PHP program
  Step 2: xgettext.exe-d test-l php -- from-code = UTF-8 index. step 3: modify test. po :#:.. /index. php: 8 msgid "Hello! "Msgstr" Hello! "#: ../Index. php: 9 msgid" World! "Msgstr" world! "#: ../Index. php: 10 msgid" Hello World! "Msgstr" Hello, world! "Step 4: msgfmt-o zh_CN/test.mo zh_CN/test. step 5 of po generation test.mo File: create the locale \ zh_CN \ LC_MESSAGES directory and put test.mo in this directory Step 6: restart apache and Access index. php to see the effect
------ Solution --------------------
Try UTF-8 encoding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.