Jump to: navigation, search

Specification:Relationship Calculator

2,692 bytes added, 22:10, 22 November 2007
no edit summary
* Translators do not have to worry about trying to translate strings such as "third cousin twice removed" into a local phrase that has no equivalent.
==How to write a relationship calculatorfor version 3.0===The relationship calculator changed for version 3.0. Logic has been separated from translation, which will allow code improvements to occur more easily, being available immediately in all translated modules. Here are the rules the language-specific plugins must obey to be compatible with the framework:# You need to make localized versions of the methods::#get_single_relationship_string:#get_sibling_relationship_string:#get_partner_relationship_string - only make a localized version of this if the gettext translation present in is not sufficient:#get_grandparents_string :Note that the signature of the methods must be identical to the ones in Relationship.pyAll other methods are unique to the English module, and should not be overwritten. You can however define your own helper functions like present in, eg _get_father(). Helper functions start with a _ and are not used outside of the Relationship class module. # Text strings returned by the function should be in the UNICODE character set. GNOME expects all displayed strings to be UNICODE characters, and most report formats use UNICODE. While it may be tempting to use ISO-8859 or other character sets, these will not display correctly and will cause errors.# The relationship plugin must register itself with the plugin system as the <code>relcalc</code> tool. This is done by inserting the following code at the end of your <code></code> file:  from PluginMgr import register_relcalc register_relcalc(RelationshipCalculatorClass,["xx","XX","xx_YY","xxxxxx","Xxxxxx","Xxxxxxx_xx"]) :where <code>RelationshipCalculatorClass</code> is the class you defined inheriting from Relationship.RelationshipCalculator, and the items in quotes are language identifiers that '''may possibly''' be associated with your language. For example, different systems use <code>ru</code>, <code>RU</code>, <code>ru_RU</code>, <code>koi8r</code>, <code>ru_koi8r</code>, <code>russian</code>, <code>Russian</code>, <code>ru_RU.koi8r</code>, etc. to identify the Russian language. That's it for the requirements. The example <code>relcalc</code> plugins can be found in <code>src/</code> and <code>src/plugins/</code> or <code>src/plugins/</code>. You are further strongly adviced to run the same tests as are present at the bottom of those files. If you have obtained GRAMPS svn in <code>/home/me/grampssvn</code>, then you can run the test for eg. as follows in a terminal:  cd /home/me/grampssvn export PYTHONPATH=/home/me/grampssvn/src python src/plugins/   ==How to write a relationship calculator in 2.2.x==
The framework for relationship calculator plugins is in place. Here are the rules the language-specific plugins must obey to be compatible with the framework:
# The relationship plugins (here and below referred to as <code>rel</code> plugins) must define a class that can be instantiated with the [ GrampsDbBase] instance as its argument and that has a <code>get_relationship()</code> method obeying the following specifications:

Navigation menu