User talk:Kim Bruning

From translatewiki.net
Latest comment: 15 years ago by Kim Bruning in topic Minimal developer documentation for .php files
translatewiki.net
Introduction
Getting started
Translation tutorial
How to start
See also
Localisation guidelines
Translating offline
FAQ
Support

Hi Kim Bruning. Welcome to translatewiki.net!

You can now start translating.

You should also check the portal for your language, the link is in the sidebar. Other useful pages are linked in the menu next to this message.

Your translations are transferred to the standard product every few days or every few weeks, depending on the product. Please notice that it may take longer before you see your translation in the actual product.

We wish you a productive and pleasant stay. Please leave any questions on Support (the link is also available on any page, in the navigation sidebar). Cheers!


Voctrain

Omegawiki-based Vocabulary trainer. Uses a flashcard system to help the user learn vocabulary from any language to any language supported by Omegawiki. Created for University of Bamberg.


Licensed GPL 2.0 or later.

Contact kim at bruning dot xs4all dot nl for inquiries.

Minimal developer documentation for .php files

Your language.i18n.php file should contain a single array called $messages

$messages=array();

...with each key being a language. English is considered default by most civilisations.

$messages["en"]=array(
        "my_application_Hello_World"=>"Hello Wiki!",
        "my_application_Test"=>"If this had been a real message, we would all be dead right now."
)

A list of accepted language codes can be found at (among others): http://svn.wikimedia.org/svnroot/mediawiki/branches/wikidata/languages/Names.php

You can also provide documentation under the fake language code "qqq"

$messages["qqq"]=array(
        "my_application_Hello_World"=>"A friendly traditional test message",
        "my_application_Test"=>"Not the emergency broadcast system"
)

For any of these per-language arrays, there are no limits to what you can use as values. For keys, at least the following limitations apply:

  • MUST NOT contain any special characters or spaces
  • MAY contain underscores, but MUST NOT have more than 2 underscores in a row.
  • Technically, unicode is permitted. Most people stick to just latin letters and numbers though
  • may contain a prefix (probably the name of your application) (this used to be a requirement. Currently betawiki is implementing namespaces, so possibly you can skip the prefix).
    • Prefix might not even be allowed to have a capital first letter (according to Nikerabbit)
  • key limitation (Translate specific): should start with lower case Latin character. (hence the prefix limitation above)

Here's a quick routine to convert an arbitrary text to a valid key that is still readable (this does not 100% ensure there will be no key collisions, but should be usable enough). YMMV:

/** safe takes a string and makes it safe for use as a key on betawiki.
 * betawiki (http://translatewiki.net/) will translate my i18n for me
 * if I do this. So it's a fair trade.
 * ( (C) Kim Bruning 2008, Released under GPLv2 or later)
 */
public static function safe($string) {

        # prefix, make sure it starts with a lowercase latin chracter for some reason. 
        $prefix="my_application_"
        if (substr_count($string,$prefix)==0) {
                $string=$prefix.$string;
        }

        # Throw out anything that doesn't look like a valid character
        # (sorry if your keys were unicode :-P )
        $string=preg_replace("|[^A-Za-z0-9_]|","_",$string);

        # Single underscores only please
        $compare="";
        while($compare!=$string) {
                $compare=$string;
                $string=str_replace("__","_",$string);
        }

        return $string;
}

If you'd like to have language fallbacks, you have to implement and maintain them yourself, Betawiki doesn't support them. (You could snarf the fallbacks off of mediawiki though).

-- Kim Bruning (talk) 23:43, 8 June 2008‎ (UTC)Reply