#226 — ITranslatable.getTranslation() implementation does not return the self like described by the interface

State Resolved
Version: 3.x
Area Functionality
Issue type Bug
Severity Medium
Submitted by Carsten Senger
Submitted on Dec 15, 2009
Target release: 3.x
Versions: 2.2, 2.4, 3.0rc4

The ITranslatable interface says:

    def getTranslation(language='language'):
        Return the object corresponding to a translated version or None.
        If called without arguments it returns the translation in the currently
        selected language, or self.

But I18NBaseObject.getTranslation() does not return self, if it is called with no argument and the prefered translation does not exist, it returns None

If you prefere to change the implementation behaviour, I can provide a unittest and a test.
But that may break existing application (e.g. I call the method without arguments and do something else than using the object itself if the method returns None.
Steps to reproduce:
create an Object in one language, switch to another language and call obj.getTranslation()
Added by Hanno Schlichting on Feb 02, 2010 03:00 PM
Issue state: UnconfirmedResolved
Target release: None3.x
The "returns self" part happens if the object is already in the selected language:

lang = self.Language()
if lang == language:
    return self

I clarified the interface description to make this more obvious and state that None is returned if no translation exits.

No responses can be added.