GrampsLocale: Prevent some AttributeErrors and 'referenced before assignment' errors.

git-svn-id: svn+ssh://svn.code.sf.net/p/gramps/code/trunk@21693 4ae1f11a-8b86-4847-b8af-ab372f36d1fd
GrampsLocale: Use glocale.lang or glocale.language[0] 

To get the default localization instead of locale.getlocale() or 
glocale.get_translation().language().

git-svn-id: svn+ssh://svn.code.sf.net/p/gramps/code/trunk@21694 4ae1f11a-8b86-4847-b8af-ab372f36d1fd
GrampsLocale: Ensure correct stdout encoding

Replace stdout with one that uses a transcoding Streamwriter. This
better handles differences between Py2 and Py3 than does trying to
encode strings prior to output. In particular Py3's default stdout
demands unencoded strings and prints byte-strings when one tries to
pre-encode them.

git-svn-id: svn+ssh://svn.code.sf.net/p/gramps/code/trunk@21695 4ae1f11a-8b86-4847-b8af-ab372f36d1fd
TreeBaseModel: Avoid TypeError when bisecting

git-svn-id: svn+ssh://svn.code.sf.net/p/gramps/code/trunk@21696 4ae1f11a-8b86-4847-b8af-ab372f36d1fd