குனு கெட்டடெக்ச்ட் பயன்படுத்தி மென்பொருளை மொழிபெயர்த்தல்

GNU gettext is one of the most widely used tool for internationalization of free software. It provides a simple yet flexible way to localize the software. It has great support for plurals, it can add further context to the translated string and there are quite a lot of tools built around it. Of course it has great support in Weblate (see குனு கெட்டெக்ச்ட் போ (சிறிய பொருள்) file format description).

Note

நீங்கள் அதை தனியுரிம மென்பொருளில் பயன்படுத்தப் போகிறீர்கள் என்றால், முதலில் உரிமத்தை அணுகவும், இது உங்களுக்கு ஏற்றதாக இருக்காது.

குனு கெட்டடெக்ச்ட் பல்வேறு மொழிகளிலிருந்து (சி, பைத்தான், பிஎச்பி, ரூபி, சாவாச்கிரிப்ட் மற்றும் பல) பயன்படுத்தப்படலாம், மேலும் பொதுவாக யுஐ கட்டமைப்புகள் ஏற்கனவே அதற்கு சில ஆதரவுடன் வருகின்றன. நிலையான பயன்பாடு 'கெட்டடெக்ச்ட் ()' செயல்பாட்டு அழைப்பு வழியாகும், இது பெரும்பாலும் குறியீட்டை எளிமையாகவும் படிக்க எளிதாகவும் மாற்ற '_()' என்று மறுபெயரிடப்படுகிறது.

கூடுதலாக இது மொழிபெயர்ப்பாளர்களுக்கு கூடுதல் சூழலை வழங்க 'பிகெட்டெக்ச்ட் ()' அழைப்பையும், இலக்கு மொழிக்கு வரையறுக்கப்பட்ட பன்மை வகைகளைக் கையாளக்கூடிய 'என்கெட்டெக்ச்ட் ()' அழைப்பையும் வழங்குகிறது.

பரவலாக பரவக்கூடிய கருவியாக, இது பல ரேப்பர்களைக் கொண்டுள்ளது, இது அதன் பயன்பாட்டை மிகவும் எளிமையாக்குகிறது, கீழே விவரிக்கப்பட்டுள்ள உரைபெறு இன் கையேடு அழைப்பதற்கு பதிலாக, அவற்றில் ஒன்றை நீங்கள் முயற்சிக்க விரும்பலாம், எடுத்துக்காட்டாக intltool.

பணிப்பாய்வு கண்ணோட்டம்

உள்ளூர்மயமாக்கலை நிர்வகிக்க குனு பல கோப்புகளைப் பயன்படுத்துகிறது:

  • PACKAGE.pot contains சரங்கள் extracted இருந்து your மூலம் code, typically using xgettext or some high நிலை wrappers such அச் intltool.

  • LANGUAGE.po contains strings with a translation to single language. It has to be updated by msgmerge once the PACKAGE.pot is updated. You can create new language files using msginit or within Weblate.

  • LANGUAGE.mo contains binary representation of LANGUAGE.po and is used at application runtime. Typically it is not kept under version control, but generated at compilation time using msgfmt. In case you want to have it in the version control, you can generate it in Weblate using mo கோப்புகளை உருவாக்குங்கள் add-on.

மொத்தத்தில் குனு கெட்டெக்ச்ட் பணிப்பாய்வு இப்படி இருக்கும்:

digraph translations { graph [fontname = "sans-serif", fontsize=10]; node [fontname = "sans-serif", fontsize=10, shape=note, margin=0.1, height=0]; edge [fontname = "monospace", fontsize=10]; "Source code" -> "PACKAGE.pot" [label=" xgettext "]; "PACKAGE.pot" -> "LANGUAGE.po" [label=" msgmerge "]; "LANGUAGE.po" -> "LANGUAGE.mo" [label=" msgfmt "]; }

மாதிரி நிரல்

கெட்டடெக்ச்டைப் பயன்படுத்தி சி இல் உள்ள எளிய நிரல் பின்வருமாறு தோன்றலாம்:

#include <libintl.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int count = 1;
    setlocale(LC_ALL, "");
    bindtextdomain("hello", "/usr/share/locale");
    textdomain("hello");
    printf(
        ngettext(
            "Orangutan has %d banana.\n",
            "Orangutan has %d bananas.\n",
            count
        ),
        count
    );
    printf("%s\n", gettext("Thank you for using Weblate."));
    exit(0);
}

மொழிபெயர்க்கக்கூடிய சரங்களை பிரித்தெடுத்தல்

Once you have code using the gettext calls, you can use xgettext to extract messages from it and store them into a .pot:

$ xgettext main.c -o po/hello.pot

Note

குறியீட்டிலிருந்து சரங்களை பிரித்தெடுக்க மாற்று நிரல்கள் உள்ளன, எடுத்துக்காட்டாக பைபாபெல்.

இது ஒரு வார்ப்புரு கோப்பை உருவாக்குகிறது, இது புதிய மொழிபெயர்ப்புகளைத் தொடங்க (msginit) அல்லது குறியீடு மாற்றத்திற்குப் பிறகு ஏற்கனவே உள்ளவற்றை புதுப்பிக்க பயன்படுத்தலாம் (அதற்காக நீங்கள் msgmerge ஐப் பயன்படுத்துவீர்கள்). இதன் விளைவாக கோப்பு வெறுமனே ஒரு கட்டமைக்கப்பட்ட உரை கோப்பு:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-23 11:02+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

#: main.c:14
#, c-format
msgid "Orangutan has %d banana.\n"
msgid_plural "Orangutan has %d bananas.\n"
msgstr[0] ""
msgstr[1] ""

#: main.c:20
msgid "Thank you for using Weblate."
msgstr ""

ஒவ்வொரு msgid வரியும் மொழிபெயர்க்க ஒரு சரத்தை வரையறுக்கிறது, தொடக்கத்தில் உள்ள சிறப்பு வெற்று சரம் மொழிபெயர்ப்பைப் பற்றிய மேனிலை தரவு கொண்ட கோப்பு தலைப்பு ஆகும்.

புதிய மொழிபெயர்ப்பைத் தொடங்குதல்

வார்ப்புருவுடன், எங்கள் முதல் மொழிபெயர்ப்பைத் தொடங்கலாம்:

$ msginit -i po/hello.pot -l cs --no-translator -o po/cs.po
Created cs.po.

The just created cs.po already has some information filled in. Most importantly it got the proper plural forms definition for chosen language and you can see number of plurals have changed according to that:

# Czech translations for PACKAGE package.
# Copyright (C) 2015 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Automatically generated, 2015.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-23 11:02+0200\n"
"PO-Revision-Date: 2015-10-23 11:02+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: cs\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ASCII\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"

#: main.c:14
#, c-format
msgid "Orangutan has %d banana.\n"
msgid_plural "Orangutan has %d bananas.\n"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""

#: main.c:20
msgid "Thank you for using Weblate."
msgstr ""

This file is compiled into an optimized binary form, the .mo file used by the GNU gettext functions at runtime.

புதுப்பித்தல் சரங்கள்

உங்கள் நிரலில் அதிக சரங்களைச் சேர்த்தால் அல்லது சில சரங்களை மாற்றியவுடன், வார்ப்புரு கோப்பை மீண்டும் உருவாக்கும் XgetText ஐ மீண்டும் இயக்குகிறீர்கள்:

$ xgettext main.c -o po/hello.pot

பின்னர் புதிதாக உருவாக்கப்பட்ட வார்ப்புருக்களுடன் பொருந்த தனிப்பட்ட மொழிபெயர்ப்பு கோப்புகளைப் புதுப்பிக்கலாம் (புதிய வார்ப்புருவுடன் பொருந்துவதற்கு சரங்களை மீண்டும் ஒழுங்கமைப்பது இதில் அடங்கும்):

$ msgmerge --previous --update po/cs.po po/hello.pot

Note

When using Weblate, you typically don't need to run msgmerge manually. Weblate can handle this automatically through the பானையுடன் பொருந்தக்கூடிய po கோப்புகளைப் புதுப்பிக்கவும் (msgmerge) add-on, or you can upload the updated POT file using the Update source strings upload method. See இலக்கு மொழி கோப்புகளைப் புதுப்பித்தல் for details.

வலைபெயர்ப்பு க்கு இறக்குமதி செய்தல்

To import such translation into Weblate, all you need to define are the following fields when creating component (see கூறு உள்ளமைவு for detailed description of the fields):

வயல்

மதிப்பு

மூல குறியீடு களஞ்சியம்

உங்கள் திட்டத்துடன் vcs களஞ்சியத்தின் முகவரி

கோப்பு முகமூடி

po/*.po

புதிய மொழிபெயர்ப்புகளுக்கான வார்ப்புரு

po/hello.pot

கோப்பு வகை

Choose gettext PO file

புதிய மொழி

Choose Create new language file

அவ்வளவுதான், நீங்கள் இப்போது உங்கள் மென்பொருளை மொழிபெயர்க்கத் தொடங்கத் தயாராக உள்ளீர்கள்!

See also

கிட்அப்பில் உள்ள வலைபெயர்ப்பு அலோ திட்டத்தில் பல மொழிகளுடன் ஒரு கெட்டடெக்ச்ட் எடுத்துக்காட்டைக் காணலாம்: <https://github.com/weblateorg/hello>.