Help:Extension:Translate/Group configuration example/da

Denne vejledning er for udviklere og avancerede oversættelses-administratorer. Vejledningen forklarer hvordan nye konfigurationsfiler oprettes til software brugergrænseflade meddelelses-oversættelse, med detaljeret beskrivelse af de tilhørende praktiske aspekter. Den skal bruges sammen med gruppe-konfiguration referencemanualen og udviklerne af Translate-udvidelsen vil med glæde hjælpe dig med eventuelle spørgsmål som du har, efter at have arbejdet dig igennem denne vejledning.

Forudsætninger

 * Installér Mediawiki
 * Installér Translate-udvidelsen og
 * konfigurér den.

Denne vejledning er lavet på grundlag af Translate-udvidelsen version r97948 (2011-09-23).

Denne vejledning beskriver processen med at aktivere oversættelse af visse dele af MyBB-projektet. Du kan følge lignende trin til at tilføje andre projekter/filer til oversættelse. Nogle ting er specifikke for translatewiki.net og du bør naturligvis bruge, hvad der er relevant i dit tilfælde i stedet for at følge trinnene i denne vejledning blindt.

Trin 1: Tjek kildekode
Let's check out the MyBB source code using  as working directory, which is   in this example.

Lad os se MyBB kildekoden ved hjælp af  som arbejdsmappe, som er   i dette eksempel. cd /home/betawiki/projects svn co http://svn.mybboard.net/mybb/branches/1.6-stable mybb

sudo -u betawiki svn co http://svn.mybboard.net/mybb/branches/1.6-stable mybb Nu skal vi finde de filer, der indeholder beskeder. De er i   underbiblioteket, og du kan finde de engelske kildemeddelelser i  -undermappen.

Så lad os starte med, den første sprog-fil i vores projekt.

Trin 2: Filformat-support
I vores MediaWiki installation bibliotek, under  og kan vi se klasser for filformater, som anvendes til at kortlægge beskedgrupper til sprog-filer af hvert projekt. Du er nødt til at kigge godt efter for at se, hvad slags formater der understøttes. Så vi beslutter at forsøge at benytte FlatPhpFFS-klasse først og se, hvor godt det virker med vores PHP-fil.

Så vi har en fil at kortlægge, og vi har valgt FFS klassen til det. Nu skal vi til at skrive en gruppe-konfiguration. Det er en YAML fil.

I indekset kan du finde et link til gruppe-konfiguration. Lad os starte med den minimale fil givet som eksempel i BASIC afsnittet. Vi kan gå videre og bare udskifte eksempelteksten med vores egne værdier. Beskrivelsen accepterer al wikitekst-syntaks. Et smart trick vist i det oprindelige eksempel er at du kan gøre den klar til oversættelse ved brug af. Men så er du nødt til at definere standardteksten på siden Mediawiki:Message-key. Bemærk, at navnerums ID tilføjes med sin konstant, se hvordan du bruger brugerdefinerede navnerum.

Vi har brug for en ting mere: -afsnittet. Igen startende fra eksemplet i dokumentationen: Hmm,  er sprogkoden, ligesom   som standard. Foreløbig ønsker vi ikke at ændre mappestrukturen, der anvendes af MyBB. I stedet kan vi bruge en funktion til dette formål: code map, som giver os mulighed for at kortlægge sprogkoder fra hvert sprog til identifikatorerne, der anvendes i vores projekt.

Så vi ender op med:

Dybest set siger dette, at for kode, vil ovenstående   være  , som er mappen til de engelske beskedfiler. Nøglen  er normalt den samme som , men uden   præfiks.

Godt. Lad os nu gemme denne fil et sted, for eksempel i den samme mappe, hvor LocalSettings.php er gemt, med navn. Hele filen er: Så må vi fortælle vores udvidelse til at læse denne fil. Tilføj følgende linje til : So let's log in, make sure the user has the "translate-manage" right configured properly, and go to Special:ManageMessageGroups.

You may see this: No valid namespace defined, got NS_MYBB. Backtrace: <...> In this case, reading the documentation carefully, you could have identified the need to add the following line to  to register the new namespace with MediaWiki: In this example 1246 is used, but you can pick any free namespace number you need. For the Translate extension, we recommend you to use the even namespace numbers 1200-1298.

If you now reload the ManageMessageGroups special page, you should see a line which says: MyBB This message group has not been imported previously. Click on the MyBB link. After that, you will see the list of messages that are in that file. If you are happy with the results, click "Execute".

After you click "Execute", the file is processed and you will see an output similar to this: 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! If the file is very large, you need to run  first, because the web interface can only import a limited number of messages at once because of the PHP timeout limit; if you encounter this limit, you can click a button at the bottom of the page to import the remaining messages.

Trin 3: Tilføje en anden fil
Now let's add a second file for MyBB for translation. There are two ways to do this:

Tilgang 1: Tilføje en ny YAML-fil
Simply add a new YAML file and save it with a new name. Then call it from inside  and follow all the above steps. The file will look something like this: 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.

Tilgang 2: TEMPLATE-syntaks
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.

Trin 4: Samlet gruppe
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 : $wgTranslateGroupStructure['/^out-mybb/'] = array( 'mybb' );

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.

Trin 5: Oprydning
YAML files of projects supported by translatewiki.net are committed to the translatewiki repository on Git.

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