Difference between revisions of "Crowdsourcing Translations/Developer Documentation"

From GeeklogWiki
Jump to: navigation, search
Line 38: Line 38:
 
====custom_string_replace.php====
 
====custom_string_replace.php====
 
Code is taken from stackoverflow, provided by user [http://stackoverflow.com/users/526741/bfrohs, bfrohs]
 
Code is taken from stackoverflow, provided by user [http://stackoverflow.com/users/526741/bfrohs, bfrohs]
Function str_lreplace
+
=====Function str_lreplace=====
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 50: Line 50:
 
|}
 
|}
  
 +
=====Function str_replace_limit=====
 +
{| class="wikitable"
 +
|-
 +
! Parameters summary
 +
|-
 +
||mixed || $search|| The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
 +
|-
 +
||mixed || $replace|| The replacement value that replaces found search values. An array may be used to designate multiple replacements.
 +
|-
 +
||mixed || $subject|| The string or array being searched and replaced on, otherwise known as the haystack. If subject is an array, then the search and replace is performed with every entry of subject, and the return value is an array as well.
 +
|-
 +
||string|| & $count|| If passed, this will be set to the number of replacements performed.
 +
|-
 +
||integer|| $limit = -1|| The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit).
 +
|}
 +
{| class="wikitable"
 +
|-
 +
! Return value summary
 +
|-
 +
||string|| This function returns a string with the replaced values.
 +
|}
 +
 +
=====Function valid_integer=====
 +
{| class="wikitable"
 +
|-
 +
! Parameters summary
 +
|-
 +
| mixed || $string ||
 +
|}
 +
 +
{| class="wikitable"
 +
|-
 +
! Return value summary
 +
|-
 +
||boolean|| Returns boolean TRUE if string is a valid integer, or FALSE if it is not
 +
|}
  
 
====functions.inc====
 
====functions.inc====
Line 56: Line 92:
 
Take a look at [http://wiki.geeklog.net/index.php/Plugin_Development, Geeklog plugin developer Guide]
 
Take a look at [http://wiki.geeklog.net/index.php/Plugin_Development, Geeklog plugin developer Guide]
 
====language_maper.php====
 
====language_maper.php====
 +
Will do the LANG array mapping
 +
 
====language_markup.php====
 
====language_markup.php====
 
+
=====Function extract_from_matches=====
 
+
{| class="wikitable"
 +
|-
 +
! Parameters summary
 +
|-
 +
|| array || $matches || matches matches found using the regex, for includes and LANG's
 +
|| array || & $push_array || the array holding all found matches without duplicates
 +
|}
 +
=====Function extract_from_matches=====
 +
{| class="wikitable"
 +
|-
 +
! Parameters summary
 +
|-
 +
|| string || $path || path of the current folder
 +
|}
 +
=====Function language_maper=====
 +
Will do the LANG array mapping
  
 
==JavaScript Documentation==
 
==JavaScript Documentation==

Revision as of 01:03, 20 September 2013

What is it?

This is a plugin that allows "crowdsourcing" the translation of Geeklog, i.e. once installed, it allows users to contribute translations of Geeklog's user interface texts for other languages.

This is a being developed by Benjamin Talic as a project during the Google Summer of Code 2013.

Major Design Decisions

  • Any logged-in user should be able to contribute a translation
  • Users can be blocked from contributing by the Admin
  • Ideally, the plugin should also allow translations of plugins (bundled and 3rd party). We'll start with core texts but try to keep things generic, adding plugin support later when possible.
  • To be able to find translations on a page at plugin installation pages are mapped into the database, data on which phrases on which pages is saved along with which pages are included in it
  • Remote contribution is allowed via a form
  • Gamification is added to the plugin
  • The plugin is placed on the left side block - the left side block is shown on more pages

PHP Documentation

plugins/crowdtranslator

sql

translations table

Saves the submitted translations

originals table

Saves the original phrase values, changing HTML and PHP code with <tag> and

votes table

Saves data on votes for translations

gems table

'List' of available gems

awarded_gems table

Data on which user got which gem awarded

language_map table

Saves data on which phrases are used on which page and which page is included on it

blocked_users table

A list of users blocked from submitting

remote_credentials table

List of sites allowed to submit translations


custom_string_replace.php

Code is taken from stackoverflow, provided by user bfrohs

Function str_lreplace
Parameters summary
mixed $search
mixed $search
mixed $search
Function str_replace_limit
Parameters summary
mixed $search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
mixed $replace The replacement value that replaces found search values. An array may be used to designate multiple replacements.
mixed $subject The string or array being searched and replaced on, otherwise known as the haystack. If subject is an array, then the search and replace is performed with every entry of subject, and the return value is an array as well.
string & $count If passed, this will be set to the number of replacements performed.
integer $limit = -1 The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit).
Return value summary
string This function returns a string with the replaced values.
Function valid_integer
Parameters summary
mixed $string
Return value summary
boolean Returns boolean TRUE if string is a valid integer, or FALSE if it is not

functions.inc

Take a look at Geeklog plugin developer Guide

install_defaults.php

Take a look at Geeklog plugin developer Guide

language_maper.php

Will do the LANG array mapping

language_markup.php

Function extract_from_matches
Parameters summary
array $matches matches matches found using the regex, for includes and LANG's array & $push_array the array holding all found matches without duplicates
Function extract_from_matches
Parameters summary
string $path path of the current folder
Function language_maper

Will do the LANG array mapping

JavaScript Documentation

Considerations

  • Ideally, translators should be able to see the text strings in context to help with the translation. - implemented
    • If that turns out not to be possible, we'll show them without context.
  • It's acceptable if the translation option slows things down. If it slows down things noticably, add a "translation mode", so users can decide between using the site normally or helping with the translation. - not necessary

More Resources

Read more about this: