Help:Extension:Translate/Group configuration example/ak

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ɛɛ 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ɛ

 * the Translate extension and
 * no.

Wɔayɛ saa nkyerɛkyerɛ yi a egyina 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  as working directory, which is   in this example.

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

Enti momma yɛnhyɛ aseɛ mfa, 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ɔ  ne    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.

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

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

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 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:  ɔfa no. Bio nso fi ase fi nhwɛso a wɔde ama wɔ nkrataa no mu no so:

Hmm,  is the language code, like   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ɛ:

Basically this says that for code, the   in above will be  , which is the directory for the English message files. The key  is usually the same as , but without the   prefix.

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

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:

Sɛ woyɛ eyi wie a, di akwankyerɛ a ɛwɔ no akyi na fa   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  ho de kyerɛw dinbea foforo no wɔ MediaWiki:

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, 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  mu na di atifi hɔ anammɔn no nyinaa akyi. Fael no bɛyɛ biribi te sɛ eyi:

As obvious in the above example, you have to use a different ID for this new group.

While easy, this approach does not scale to hundreds of different translation units (i.e. files mapped to their message group). At some point you need to update some value, and doing it for all those files is no fun. Fortunately there is another way, shown below.

Approach 2: TEMPLATE syntax
The idea is that we pull common values into a template. Then each group will take missing values from the template and there is no need to repeat them for every group.

Let's get back to MyBB example. Let's say you want to include,   and   in the translatable messages. The YAML file needs to be updated like this:

As obvious in the above example,  is defined only once; addition and removal of files is as easy as adding or removing a section in the above file.

Now if you go to the ManageMessageGroups special page, you will see three items like this:

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.

If there are a lot of files to be included in your project, it may be a good idea to write a script that generated your YAML file for you. An example can be found in trunk/translatewiki/StatusNet/genStatusNet-plugins.php.

Step 4: Aggregate group
Adding an aggregate group and defining the message files as its subgroups has two benefits:


 * Less work for translators to select different message groups, in particular for maintenance work. Translators can simply open the aggregate group and translate or update everything that needs updating or translation for all the groups.
 * Statistics can be reported on the aggregate group level, i.e. whole project.

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:

This gets us pretty close, but there is still one step missing. At this point, if you go to Special:Translate, you will see the MyBB parent group (and it in fact works!) but also the subgroups listed as separate groups. :(

This is the way to fix it. Add the following line to your :



This takes all groups whose id match the given pattern, shows the first group, and hides everything else below that first group. A bit ugly, but it works. This construction only supports two layers, even though aggregate groups can be part of aggregate groups.

If you go to Special:Translate now, you will only see the parent group MyBB listed. Additionally, you will see a link "Show 3 subgroups"; clicking on that will show you the names of subgroups.

Check out the manual for TAGS and other sections we didn't go through in this document.

Step 5: Cleaning up
YAML files of projects supported by translatewiki.net are committed to the repository on Git.

In translatewiki.net, the  lines are actually in. Sandboxwiki at translatewiki.net does not have a  file, which is why we added everything in.