Iconv and getText IMPLEMENT STEP

zhaozj2021-02-16  43

Refer to http://www.onlamp.com/pub/a/php/2002/06/13/php.html

1. Install iconv and gettext module and make configure ON Server

Download libiconv-1.9.1.tar.gz, gettext-0.12.1.tar.gz, apache_1.3.22.tar.gz, php-4.2.tar.gz

[libiconv] ./ Configure --prefix = / usr / local --enable-extra-encodingsmakemake install [gettext] ./ Configure --prefix = / usr / localmakemake install

[Apache] ./ Configure --prefix = / usr / local / apache --enable-module = somakemake install / usr / local / apache / bin / apachectl stop [php] ./ Configure --with-oci8 = / home / Oracle / orahome1 --with-apxs = / usr / local / apache / bin / apxs --enable-sigchild --with-mysql = / usr / local / mysql --with-iconv = / usr / local --with- GetText = / usr / local --enable-track-vars --enable-mbstring = allmakemake install]

/ usr / local / apache / bin / apachectl start

2. GetText IMPLEMENT STEP

1) WRITE PHP File Using GetText Function

For example:

$ lGuage = 'zh_cn';

Putenv ("lang =". $ tanguage);

Putenv ("Language =". $ tanguage);

$ newlocale = setlocale (lc_all, $ tanguage);

Echo "Current Locale:" $ newlocale. "
";

// set the text domain as 'Messages'

$ domain = 'messages';

BindtextDomain ($ domain, "./locale);

TextDomain ($ domain);

Echo gettext ("Hello Everyone");

Print (_ ("Hello World"));

?>

2) Setting Up The GetText Locale DIRECTORY

/ locale

/ EN

/ LC_MESSAGES

Messages.po

Messages.mo

/ zh_cn

/ LC_MESSAGES

Messages.po

Messages.mo

3) Extracts translatable strings and generate * .po files to translate

$ XGettext -n * .php

Message.po:

# Some Descriptive Title.

# CopyRight (C) Year The Package's Copyright Holder

# This file is distributed under the single license as the package packag # first author , year.

#

#, fuzzy

"Msgid" "

"Msgstr" "

"Project-id-version: package version / n"

"Report-msgid-bugs-to: / n"

Pot-Creation-Date: 2004-01-16 03: 28 0000 / N "

"Po-revision-date: Year-Mo-da HO: MI ZONE / N"

"Last-Translator: full name / n"

"Language-Team: Language / n"

"MIME-VERSION: 1.0 / N"

"Content-Type: Text / Plain; Charset = Charset / N"

"Content-Transfer-Encoding: 8bit / N"

#: getText.php: 23

Msgid "Hello Everyone"

"Msgstr" "

#: getText.php: 24

Msgid "Hello World"

"Msgstr" "

4) Fill Translation of Msgid Into Msgstr and Convert * .po to * .mo

$ msgfmt messages.po

$ CP messages.mo locale / zh_cn / lc_messages /

5) Maintain Translation Message File-Msgmerge

For example:

LS

EXAMPLE.PHP

$ XGettext -n * .php

$ ls

Example.php messages.po

// ...

// Translates the messages.po file now

// ...

$ msgfmt messages.po

$ ls

Example.php messages.po messages.mo

// ...

// changes the example.php file

// ...

$ mv messages.po ild.po

$ XGettext -n * .php

$ ls

Example.php messages.po messages.mo ild.po

$ msgmerge old.po messages.po --output-file = new.po

$ ls

Example.php messages.po message.mo new.po old.po

// ...

// translates the new.po file

// ...

$ msgfmt new.po

转载请注明原文地址:https://www.9cbs.com/read-25929.html

New Post(0)