Mmoa:Ntrɛwmu:Nkyerɛase/Kuw nhyehyɛe nhwɛso

This page is a translated version of the page Help:Extension:Translate/Group configuration example and the translation is 85% complete.

Saa nkyerɛkyerɛ yi yɛ ma developers ne nkyerɛaseɛ so ahwɛfoɔ a wɔakɔ anim. This tutorial explains how to create new configuration files for software interface message translation, detailing the practical aspects of it. Ɛsɛ sɛ wode bedi dwuma abom ne kuo nhyehyeɛ nkyerɛkyerɛmu nwoma na wɔn a wɔyɛɛ Translate ntrɛmu no de anigyeɛ bɛboa wo wɔ nsɛmmisa biara a wowɔ ho bere a woayɛ adwuma wɔ nkyerɛkyerɛ yi mu awie no.

Nneɛma a ɛsɛ sɛ wodi kan yɛ

Wɔayɛ saa nkyerɛkyerɛ yi a egyina Translate ntrɛwmu nsakrae r97948 (2011-09-23) so.

Saa nkyerɛkyerɛ yi kyerɛkyerɛ ɔkwan a wɔfa so ma nkyerɛase tumi yɛ MyBB adwuma no afa horow bi. Wubetumi adi anammɔn a ɛte saa ara akyi de nnwuma/fael afoforo aka ho ama nkyerɛase. Nneɛma bi yɛ translatewiki.net pɔtee na ɛsɛ sɛ wode nea ɛfa wo ho no di dwuma fi awosu mu, sen sɛ wubedi nkyerɛkyerɛ yi anammɔn akyi anifurae so.

Step 1: Check out source code

Let's check out the MyBB source code using $wgTranslateGroupRoot as working directory, which is /home/betawiki/projects/ in this example.

cd /home/betawiki/projects svn co http://svn.mybboard.net/mybb/branches/1.6-stable mybb

Ɛgyina wo nhyehyɛɛ so no, ebia ɛho behia sɛ woyɛ eyi sɛ root anaa ɔdefo foforo ansa na wode project fael anaa nhyehyeɛ fael ahorow aka ho. Wɔ translatewiki.net so no, ɔdefo no yɛ "betawiki", enti atifi hɔ ahyɛde no yɛ nokwarem sɛ:

sudo -u betawiki svn co http://svn.mybboard.net/mybb/branches/1.6-stable mybb

Afei ɛsɛ sɛ yɛhwehwɛ fael ahorow a nkrasɛm ahorow no wom no. Wɔwɔ mybb/inc/languages/ subdirectory no mu, na wobɛtumi ahunu Twi farebae nkrasɛm no wɔ english/ subdirectory no ase.

Enti momma yɛnhyɛ aseɛ mfa mybb/inc/languages/english/index.lang.php, yɛn adwuma no localization fael a ɛdi kan.

Step 2: File Format Support

Wɔ yɛn MediaWiki instɔlehyɛn daerekta mu no, wɔ FFS.php ne Translate/ffs/ [1] ase no yebetumi ahu adesua ahorow a ɛfa fael format mmoa ho, a wɔde yɛ map nkra akuw kɔ localization fael ahorow so adwuma biara ho. Ɛsɛ sɛ woyɛ digging kakra na woahu ankasa sɛ formats ko a wɔboa. Enti yɛsi gyinae kɛkɛ sɛ yɛbɛbɔ mmɔden na yɛde FlatPhpFFS adesua no adi kan adi kan na yɛahwɛ sɛnea ɛyɛ adwuma yiye wɔ yɛn PHP fael no ho.

Enti yɛwɔ fael a yɛde bɛyɛ map na yɛapaw FFS class no ama no. Afei ɛsɛ sɛ yɛkyerɛw kuw nhyehyɛe bi. Ɛno yɛ YAML fael.

index mu no wobɛtumi ahunu link a ɛkɔ Kuo nhyehyɛɛ . Momma yɛnhyɛ aseɛ mfa fael a ɛsua koraa a wɔde ama sɛ nhwɛsoɔ ama MFIASESƐMɔfa no.

BASIC:
  id: out-freecol
  label: FreeCol (open source game)
  description: "{{int:bw-desc-freecol}}"
  namespace: NS_FREECOL
  class: FileBasedMessageGroup

Yebetumi akɔ yɛn anim na yɛde yɛn ankasa gyinapɛn ahorow asi nhwɛso nkyerɛwee no ananmu kɛkɛ.

BASIC:
  id: out-mybb
  label: MyBB
  description: "[[Translating:MyBB|MyBB]] is a web-based discussion forum software"
  namespace: NS_MYBB
  class: FileBasedMessageGroup

Nkyerɛkyerɛmu no gye wikitext syntax nyinaa tom. Afiri fɛfɛ baako a wɔakyerɛ wɔ mfitiaseɛ nhwɛsoɔ no mu ne sɛ wobɛtumi ama no atumi akyerɛ aseɛ denam {{int:message-key}} a wode bedi dwuma no so. Nanso afei ɛsɛ sɛ wokyerɛkyerɛ default text no mu wɔ krataafa [[MediaWiki:Message-key]] no mu. Hyɛ no nsow sɛ wɔde edin atenae ID no nam ne daa so aka ho, hwɛ sɛnea wode edin atenae a wɔahyɛ da ayɛ di dwuma.

Yɛhia adeɛ baako bio: fael ahorow ɔfa no. Bio nso fi ase fi nhwɛso a wɔde ama wɔ nkrataa no mu no so:

FILES:
  class: FlatPhpFFS
  sourcePattern: %GROUPROOT%/inc/languages/messages_%CODE%.properties
  targetPattern: commonist/messages_%CODE%.properties

Hmm, %CODE% is the language code, like en by default. For now, we do not want to change the directory structure used by MyBB. Instead we can use a feature designed for this purpose: the code map, which allows us to map language codes of each language to the identifiers used by our project.

Enti yekowie sɛ:

FILES:
  class: FlatPhpFFS
  sourcePattern: %GROUPROOT%/mybb/inc/languages/%CODE%/index.lang.php
  targetPattern: mybb/inc/languages/%CODE%/index.lang.php
  codeMap:
    en: english
    "no": norwegian
Hwɛ yie, wobɛhia nsɛm a wɔafa aka atwa kasa koodu no ho ahyia, ɛfiri sɛ YAML parsers binom kyerɛ aseɛ sɛ boolean.

Basically this says that for code en, the %CODE% in above will be english, which is the directory for the English message files. The key targetPattern is usually the same as sourcePattern, but without the %GROUPROOT% prefix.

Good. Now let's save this file somewhere, for example to the same folder where LocalSettings.php is stored, with name MyBB.yaml. The whole file is:

BASIC:
  id: out-mybb
  label: MyBB
  description: "[[Translating:MyBB|MyBB]] is a web-based discussion forum software"
  namespace: NS_MYBB
  class: FileBasedMessageGroup

FILES:
  class: FlatPhpFFS
  sourcePattern: %GROUPROOT%/mybb/inc/languages/%CODE%/index.lang.php
  targetPattern: mybb/inc/languages/%CODE%/index.lang.php
  codeMap:
    en: english
    "no": norwegian

Papa. Afei momma yɛmfa saa fael yi nsie baabi, sɛ nhwɛso no, nkɔ folda koro no ara a wɔde $1 asie no mu, a edin $2 wom. Fael no nyinaa ne:

$wgTranslateGroupFiles[] = "MyBB.yaml";

Sɛ woyɛ eyi wie a, di akwankyerɛ a ɛwɔ Help:Extension:Translate/Group management no akyi na fa processMessageChanges.php script no di dwuma.

Enti momma yɛnkɔ mu, hwɛ sɛ ɔdefoɔ no wɔ "translate-manage" hokwan wɔahyehyɛ no yie, na kɔ [[Special:ManageMessageGroups]].

Ebia wubehu eyi:

No valid namespace defined, got NS_MYBB.
Backtrace: <...>

Wɔ saa tebea yi mu no, sɛ wokenkan nkrataa no yiye a, anka wubetumi ahu hia a ehia sɛ wode nkyerɛwde a edidi so yi ka LocalSettings.php ho de kyerɛw dinbea foforo no wɔ MediaWiki:

wfAddNamespace( 1246, 'MyBB' );

Wɔ saa nhwɛso yi mu no wɔde 1246 na edi dwuma, nanso wubetumi apaw dinbea nɔma biara a wontua hwee a wuhia. Sɛ wopɛ Translate ntrɛwmu no a, yɛhyɛ nyansa sɛ fa even namespace nɔma 1200-1298 di dwuma.

Sɛ afei wosan de ManageMessageGroups krataafa titiriw no gu mu a, ɛsɛ sɛ wuhu line bi a ɛka sɛ:

MyBB This message group has not been imported previously.

Klik MyBB link no so. Ɛno akyi no, wubehu nkrasɛm ahorow a ɛwɔ saa fael no mu no din. Sɛ w'ani gye nea efi mu ba no ho a, klik "Execute".

Sɛ wo klik "Execute" wie a, wɔyɛ fael no ho adwuma na wubehu output a ɛte sɛ eyi:

Imported new version of page MyBB:L\x5b'boardstats'\x5d/en.
Imported new version of page MyBB:L\x5b'new posts'\x5d/en.
Imported new version of page MyBB:L\x5b'no new posts'\x5d/en.
...
Cache rebuild.
All done!

Sɛ fael no sõ yiye a, ɛsɛ sɛ wudi kan tu mmirika php Translate/scripts/sync-group.php --group=out-mybb --lang=en, efisɛ wɛb ntamgyinafo no betumi de nkra dodow bi aba prɛko pɛ esiane PHP bere a ɛtwam anohyeto no nti; sɛ wuhyia anohyeto yi a, wubetumi akliki bɔtn bi a ɛwɔ kratafa no ase no so de nkrasɛm a aka no aba.

Anamɔn 3: Fael foforo a wode bɛka ho

Afei momma yɛmfa fael a ɛtɔ so mmienu nka ho mma MyBB mma nkyerɛaseɛ. Akwan abien na ɛwɔ hɔ a wobɛfa so ayɛ eyi:

Ɔkwan 1: YAML fael foforo a wode bɛka ho

Fa YAML fael foforo ka ho kɛkɛ na wode din foforo sie. Afei frɛ no fi LocalSettings.php mu na di atifi hɔ anammɔn no nyinaa akyi. Fael no bɛyɛ biribi te sɛ eyi:

BASIC:
  id: out-mybb-showthread
  label: MyBB
  description: "[[Translating:MyBB|MyBB]] is a web-based discussion forum software"
  namespace: NS_MYBB
  class: FileBasedMessageGroup

FILES:
  class: FlatPhpFFS
  sourcePattern: %GROUPROOT%/mybb/inc/languages/%CODE%/showthread.lang.php
  targetPattern: mybb/inc/languages/%CODE%/showthread.lang.php
  codeMap:
    en: english
    "no": norwegian

Sɛnea ɛda adi wɔ atifi hɔ nhwɛso no mu no, ɛsɛ sɛ wode ID soronko di dwuma ma kuw foforo yi.

Ɛwom sɛ ɛyɛ mmerɛw de, nanso saa kwan yi ntumi nkɔ nkyerɛase akuw ahorow ɔhaha pii (i.e. fael ahorow a wɔayɛ ho mfonini wɔ wɔn nkra kuw no mu). Ɛdu baabi a ɛsɛ sɛ wo update value bi, na sɛ wobɛyɛ ama saa fael ahorow no nyinaa a, ɛnyɛ anigye. Nea eye ne sɛ ɔkwan foforo bi wɔ hɔ, a wɔakyerɛ wɔ ase ha.

Approach 2: TEMPLATE syntax

Adwene no ne sɛ yɛbɛtwe gyinapɛn ahorow a wɔtaa de di dwuma no akɔ nsusuwso bi mu. Afei kuw biara bɛfa values a ayera afi template no mu na ɛho nhia sɛ wɔsan yɛ no bio ma kuw biara.

Momma yɛnsan nkɔ MyBB nhwɛso no so. Momma yɛnka sɛ wopɛ sɛ wode index.lang.php, showthread.lang.php ne global.lang.php ka nkra a wobetumi akyerɛ ase no ho. Ɛsɛ sɛ wɔyɛ YAML fael no foforo te sɛ eyi:

TEMPLATE:
  BASIC:
    description: "[[Translating:MyBB|MyBB]] is a web-based discussion forum software"
    namespace: NS_MYBB
    class: FileBasedMessageGroup

  FILES:
    class: FlatPhpFFS
    codeMap:
      en: english
      "no": norwegian
---
BASIC:
  id: out-mybb-index
  label: MyBB - index page

FILES:
  sourcePattern: %GROUPROOT%/mybb/inc/languages/%CODE%/index.lang.php
  targetPattern: mybb/inc/languages/%CODE%/index.lang.php
---
BASIC:
  id: out-mybb-showthread
  label: MyBB - show thread

FILES:
  sourcePattern: %GROUPROOT%/mybb/inc/languages/%CODE%/showthread.lang.php
  targetPattern: mybb/inc/languages/%CODE%/showthread.lang.php
---
BASIC:
  id: out-mybb-global
  label: MyBB - global messages

FILES:
  sourcePattern: %GROUPROOT%/mybb/inc/languages/%CODE%/global.lang.php
  targetPattern: mybb/inc/languages/%CODE%/global.lang.php
Hyɛ no nsow sɛ ɛsɛ sɛ wɔde nkyerɛwde a ɛwɔ dash abiɛsa --- a mfiase ne akyi ntam kwan biara nni mu na ɛtetew kuw biara mu! Sɛ ɛnte saa a, wɔrenkyekyɛ YAML fael no mu yiye.

Sɛnea ɛda adi wɔ atifi hɔ nhwɛso no mu no, wɔakyerɛkyerɛ codeMap mu pɛnkoro pɛ; fael ahorow a wode bɛka ho na woayi afi hɔ no yɛ mmerɛw te sɛ nea wode ɔfã bi bɛka ho anaasɛ wubeyi afi fael a ɛwɔ atifi hɔ no mu.

Afei sɛ wokɔ ManageMessageGroups krataafa titiriw no so a, wubehu nneɛma abiɛsa te sɛ eyi:

MyBB global messages: This message group has not been imported previously.
MyBB index page: This message group has not been imported previously.
MyBB show thread: This message group has not been imported previously.

Sɛ fael pii wɔ hɔ a ɛsɛ sɛ wode ka wo project no ho a, ebia ɛbɛyɛ adwene pa sɛ wobɛkyerɛw script a ɛde wo YAML fael no bae maa wo. Wobetumi ahu nhwɛso bi wɔ $kratafa mu.

Anamɔn 4: Ka kuw no bom

Sɛ wode kuw a wɔaka abom bɛka ho na woakyerɛ nkrasɛm fael ahorow no ase sɛ ne akuw nketewa no wɔ mfaso abien:

  • Adwuma kakraa bi ma nsɛm asekyerɛfo de paw nkrasɛm akuw ahorow, titiriw ma nsiesie adwuma. Nsɛm asekyerɛfo betumi abue kuw a wɔaka abom no ara kwa na wɔakyerɛ ase anaasɛ wɔayɛ biribiara a ehia sɛ wɔyɛ no foforo anaa wɔkyerɛ ase ma akuw no nyinaa ase foforo.
  • Wobetumi abɔ akontabuo ho amanneɛ wɔ kuw a wɔaka abom no gyinabea, i.e. adwuma no nyinaa.

In order to define an aggregate group, you need to add the following section right after the TEMPLATE section and before the definition of individual subgroups:

---
BASIC:
  id: out-mybb-0-all # The id should sort before all the subgroups it has
  label: MyBB
  meta: yes
  class: AggregateMessageGroup # Not taken from template

GROUPS:
  - out-mybb-* # We could specify them one by one, but wildcard is easier

Eyi ma yɛbɛn yɛn yiye, nanso anammɔn biako da so ara yera. Saa berɛ yi, sɛ wokɔ Special:Translate a, wobɛhunu MyBB awofoɔ kuo no (na nokwarem no ɛyɛ adwuma!) nanso akuo nketewa a wɔakyerɛw sɛ akuo ahodoɔ nso. :(

Eyi ne ɔkwan a wɔfa so siesie. Fa nkyerɛwde a edidi so yi ka wo LocalSettings.php ho:

$wgTranslateGroupStructure['/^out-mybb/'] = array( 'mybb' );
 
Wɔatrɛw kuw bi a wɔaka abom mu (hwɛ no collapsed)

Eyi fa akuw a wɔn id ne nhwɛso a wɔde ama no hyia nyinaa, kyerɛ kuw a edi kan no, na ɛde biribiara a aka wɔ saa kuw a edi kan no ase no sie. Ɛyɛ fɛ kakra, nanso ɛyɛ adwuma. Saa adansi yi boa ntoatoaso abien pɛ, ɛwom mpo sɛ akuw a wɔaka abom betumi ayɛ akuw a wɔaka abom no fã de.

Sɛ wo kɔ [[Special:Translate]] seesei a, wobɛhunu awofoɔ kuo MyBB nko ara a wɔakyerɛw din. Bio nso, wobɛhunu link bi "Kyerɛ akuw nketewa 3"; sɛ wobɔ so a, ɛbɛkyerɛ wo akuw nketewa din.

Hwɛ nwoma a ɛfa TAGS ne afã foforɔ a yɛankɔ mu wɔ saa nwoma yi mu.

Anamɔn 5: Ahotew

YAML fael ahorow a ɛfa nnwuma a translatewiki.net boa ho no, wɔde ahyɛ $git-fael akorae a ɛwɔ Git so.

Wɔ translatewiki.net mu no, LocalSettings.php nkyerɛwde no wɔ TranslateSettings.php mu ankasa. Sandboxwiki a ɛwɔ translatewiki.net no nni TranslateSettings.php fael, ɛno nti na yɛde biribiara kaa ho wɔ LocalSettings.php mu no.