Extracting multi-language placeholders in C # using GetText (Nopcommerce sample article)

Source: Internet
Author: User

i18n internationalization The usual practice is to use the gettext, that is, the use of special keywords in the source code to identify the string will probably be translated, such as

@if (model.iscustomerforummoderator)            {                class='status'>                    <label>@t ("  Forum.status"):</label>                    <span>@t ("forum.moderator" ) </span>                </li>            }

@T ("xxxx") This code means to translate the word "forum.status".

So how do we extract these strings after we have developed a project? In fact, at least 20 years ago, this tool was already in effect, and (https://www.gnu.org/software/gettext/) Xgettext.exe was doing it.

GetText has quite a long documentation, contains a lot of tools, and extracts strings with Xgettext

1. First we have to tell xgettext what the input source is.

We use the following code to generate a list of files to be extracted

dir *.cshtml/s/b>cshtml.list

Output files are similar

2. Using Xgettext to generate PO files

Xgettext--files-from= "C:\Users\ user name \documents\opensource\nop\presentation\nop.web\cshtml.list"--output-dir=c:\ Noptext--language=c#-kt-knopresourcedisplayname--from-code=utf-8

* Need to create a directory Noptext (you can specify it yourself),-kt, indicate t as the keyword

The resulting PO file is:

With the PO file you can use translation tools to translate!!

Client tools are recommended here https://poedit.net/

Or the famous Crowdin on the line (fee): https://crowdin.com/

-----------------------------------------------------AD Divider--------------------------------------------------------------- ----------------------------

Finally, welcome to the NOP translation project.

Https://crowdin.com/project/nopcommerce

Extracting multi-language placeholders in C # using GetText (Nopcommerce sample article)

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.