new project: Huggle
Hello, on new project instruction I was sent to #mediawiki-i18n, in that channel I was sent here. I would like to request a set up of new project (huggle) so that we can manage translations through this wiki and make it easier for translators to translate interface. We are using
key: value
format which is very easy to parse even by humans or machines and is very suitable for any translations. However I was told that this wiki is unable to parse this simple format. Parser for this format is a matter of 3 lines of code, but if you want I will write it. Thank you Petrb (talk) 15:17, 10 January 2014 (UTC)
Yep, please write it: as you chose an unsupported format, TWN has no resources to implement it (I tell you for your good :) ). As Nikerabbit mentioned, your format is similar to .properties files like:
# Messages for French (français) # Exported from translatewiki.net # Author: Nisard index.quote=Que l'Amour s'introduise auprès d'elle sous le voile de l'amitié
so you can probably adapt https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FTranslate/HEAD/ffs%2FJavaFFS.php Even better if you can also commit a configuration patch after that (or after you pick a supported format); the format is documented but you can see e.g. [1] and [2] for the needed set of files/configs.
Whatever happens, please remember to keep this thread (and/or its summary above) up to date as regards the status of things and what the next steps are, so that it doesn't get stuck.
here is the code, I have no idea what coding style you require, so feel free to reformat, it's obviously longer than 3 lines, because I add some comments and error checks too :-)
/*!
* \brief Parses a line of translation text
* \param line Line in ^key:\s*value$ syntax
* \return array with 2 elements key and value or NULL in case that line can't be parsed
*/
function ParseLine($line)
{
$colon_position = strpos($line,':');
// check if there is colon in line
if ($colon_position === false)
{
return NULL;
}
$key = substr( $line, 0, $colon_position );
$value = substr ( $line, $colon_position + 1 );
while ( strpos($value, " ") === 0 )
{
$value = substr ( $value, 1 );
}
return [ $key => $value ];
}
no this is php.
anyway, where can I find documentation for that FFS format you talk about? this piece of french text isn't very self-describing. Thanks!
Petrb, are you still interested in working on this? Were the links above to other FFS not useful? Let us know if you get stuck at some point with the gerrit patches in Translate/translatewiki repos.
it seems easier if we just change the format to something what is sane and easy to parse, so from current list of formats supported by this extension, only properly supported format I found was XML, so I would probably go for that. What is next step, you can assume all our language files are XML now.