Commit Graph

248 Commits

Author SHA1 Message Date
John Ralls
56254d4a14 GrampsLocale: Integrate libtranslate functions into GrampsLocale
And remove libtranslate

svn: r21967
2013-04-12 22:27:54 +00:00
John Ralls
27f667e343 GrampsLocale: Add get_date and get_type functions
To enable GrampsLocale to replace libtranlate.py's Translation
class.

svn: r21965
2013-04-12 22:27:32 +00:00
John Ralls
db66851363 GrampsLocale: Add date_parser and date_displayer properties
svn: r21964
2013-04-12 22:27:23 +00:00
John Ralls
6f078627ca MacLocale: Capture collation qualifications
svn: r21963
2013-04-12 22:27:15 +00:00
John Ralls
2c532baf1c GrampsLocale: Make dictionaries class variables
lang_map and country_map

svn: r21962
2013-04-12 22:27:05 +00:00
John Ralls
a422b30fd6 GrampsLocale: Refactor/clean up initialization
Includes moving encoding to be a class variable.

svn: r21961
2013-04-12 22:26:55 +00:00
John Ralls
01b4b7dc4e GrampsLocale: Ensure self.encoding exists before testing it
svn: r21899
2013-04-05 23:40:55 +00:00
John Ralls
e21ba6c432 GrampsLocale: Clean up _init_from_environment even more
And do it right this time!

svn: r21898
2013-04-05 23:40:49 +00:00
John Ralls
b72ddb7f47 GrampsLocale: Improve windows handling of no locale
svn: r21882
2013-04-04 21:06:19 +00:00
John Ralls
04c146669b GrampsLocale: Ensure posix collation and calendar are set correctly
svn: r21881
2013-04-04 21:06:09 +00:00
John Ralls
fc23bbd93a GrampsLocale: Better handling of unset $LANG or $LANG == 'C'
svn: r21880
2013-04-04 21:04:48 +00:00
John Ralls
a8c7156b76 GrampsLocale: Fix MSWin Syntax error
Can't do everything the C way :-(

svn: r21858
2013-04-03 03:55:17 +00:00
John Ralls
ea9ddaba69 GrampsLocale: Win: Check both forward and reverse mslocale
svn: r21854
2013-04-02 20:25:08 +00:00
John Ralls
a15e676eef [Bug 6495] Translator class should use english date
When "English" is set via libtranslate.

svn: r21844
2013-04-02 00:05:50 +00:00
John Ralls
a3cc615398 GrampsLocale: Fix NoneType error
svn: r21839
2013-04-01 17:34:26 +00:00
John Ralls
0cab5e576c GrampsLocale: Better initialization from environment
Splits out Win32 and Posix initializations to take account of the
fact that on Win32 setlocale() ignores environment variables and on
Posix it's not necessary to check them because setlocale() does the
right thing.

svn: r21830
2013-03-31 22:46:25 +00:00
John Ralls
f432853dc4 GrampsLocale: Separate self.encoding from sys.stdout.encoding
Because python standard library functions encode to
locale.getpreferredencoding or sys.getdefaultencoding, not to
sys.stdout.encoding.

svn: r21753
2013-03-26 19:16:49 +00:00
Nick Hall
5adc2102a2 Add Tag class to CallbackManager
svn: r21727
2013-03-23 22:26:35 +00:00
John Ralls
548507008b 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.

svn: r21695
2013-03-19 18:22:19 +00:00
John Ralls
ec787da3fa GrampsLocale: Prevent some AttributeErrors and 'referenced before assignment' errors.
svn: r21693
2013-03-19 18:21:41 +00:00
Tim G L Lyons
d643dde344 Standardise messages about missing modules to include problem, consequence and what to do about it (currently including references to GEPS 029 where necessary).
svn: r21671
2013-03-17 11:40:33 +00:00
John Ralls
29292a404a GrampsLocale: Code cleanup
And make sure that setting lang on the GrampsLocale constructor
overrides the languages from the first instance.

svn: r21646
2013-03-14 23:01:09 +00:00
John Ralls
66ded552dd GrampsLocale: Suppress double printing of log messages
Grampsapp.py sets a global handler, so install one only during the first init and remove it when done.

svn: r21644
2013-03-14 23:00:57 +00:00
John Ralls
c25d94b3a7 GrampsLocale: Reduce circular imports
Lets one import grampslocale directly in a test script:
>>> from gramps.gen.utils.grampslocale import GrampsLocale
>>> import os
>>> gl = GrampsLocale(lang='fr_FR.UTF-8', localedir=os.path.join('build', 'mo'))
>>> tr = gl.get_translation().gettext
>>> tr("List of known family trees in your database path\n")
u'Liste des arbres familiaux connus dans votre chemin de base de donn\xe9es\n'

svn: r21640
2013-03-13 00:05:46 +00:00
John Ralls
f270f08be8 GrampsLocale: Better handle invalid/missing locale
svn: r21636
2013-03-12 22:22:58 +00:00
John Ralls
9e844f0d64 MacLocale: Extract function _mac_get_gramps_defaults
And correct line handling on the languages list.

svn: r21635
2013-03-12 22:22:53 +00:00
John Ralls
33d9b19ac7 GrampsLocale: Ensure that encoding gets set to something
In the C locale, locale.getlocale() returns [None, None]

svn: r21616
2013-03-11 22:44:29 +00:00
John Ralls
fa0eb6cebe Determine Paths at Runtime
Uses GRAMPS_RESOURCES to override the root location of the Gramps data files (which would normally be $(prefix)/share).
In setup.py install, writes $(prefix)/share to gen/utils/resource-path, installs that file, then deletes it again from the source tree. The presence or absence determines whether Gramps is running from the source directory or from an installation.

Const.py is now a static file; const.py.in is no longer used. Note that because importing const into setup tried to initialize things that we don't want initialized, VERSION is removed, and imported from gramps.version -- a file which will be added in the next change. Consequently, this commit will not run.

svn: r21613
2013-03-11 22:43:58 +00:00
John Ralls
56e29c162b GrampsLocale: Protect another setlocale instance
svn: r21612
2013-03-11 22:43:52 +00:00
Paul Franklin
55e2863a0b sync a few files in gramps40 and trunk
svn: r21603
2013-03-10 21:51:52 +00:00
John Ralls
b60dbf2782 Grampslocale: Protect from crashes due to passing bad strings to setlocale
svn: r21597
2013-03-09 22:31:13 +00:00
John Ralls
40ff796d93 Mac: Improve language list handling
Make sure that lang overrides the language list only if $LANG is set. Don't add encodings to the language list (e.g., en_US, not en_US.UTF-8). Start collation with None, because `if collation:` is True for collation = "". defaults may have whitespace at the end of "root", so use "startswith".

svn: r21596
2013-03-09 22:31:06 +00:00
John Ralls
068d50cc26 GrampsLocale: Improve handling the language list
Replace "en" with "C" when setting $LANGUAGE ("en" confuses GtkBuilder), and explicitly iterate over languages when finding
the translator, because left to itself gettext will ignore English.

svn: r21595
2013-03-09 22:31:00 +00:00
Jérôme Rapinat
9856e108e6 "os" is not defined
svn: r21588
2013-03-09 12:15:39 +00:00
John Ralls
b262eeaab7 get_unicode_path_from_env_var(): make no-op if it's already unicode
svn: r21561
2013-03-06 01:07:05 +00:00
John Ralls
b57e7b7508 GrampsLocale:Move setlocale from _set_from_environment to __init_first_instance
So that encoding is set for Mac as well.

svn: r21554
2013-03-05 17:23:21 +00:00
John Ralls
694f757463 GrampsLocale: Add _win_bindtextdomain
Adapted from init_windows_gettext in Gramps3.
Libintl-8.dll must be on the path, just like all of the other C-library
dependencies.



svn: r21540
2013-03-03 23:40:27 +00:00
John Ralls
649bdf7bb7 GrampsLocale: Restore setlocale, add GrampsLocale.encoding
encoding to replace translation().info()['encoding'] which isn't 
the encoding we're looking for. 

svn: r21539
2013-03-03 21:55:02 +00:00
John Ralls
f6ab91e87f GrampsLocale: Create GrampsTranslation attribute for language
Rather than relying on translators to correctly fill out po files

svn: r21526
2013-03-02 20:25:07 +00:00
John Ralls
67e975b31f GrampsLocale: Fix glocale without import
svn: r21525
2013-03-02 20:25:01 +00:00
John Ralls
ee7fdca6ef MacLocale: Handle AppleCollationOrder returning "root"
svn: r21491
2013-02-28 18:57:37 +00:00
John Ralls
1e41e76682 MacLocale: Allow $LANG to override defaults settings
For currency, calendar, and collation

svn: r21490
2013-02-28 18:57:31 +00:00
John Ralls
991447264a GrampsLocale: Handle errors in getting collation key from locale module
svn: r21489
2013-02-28 18:57:25 +00:00
John Ralls
38dcbbae58 GrampsLocale: Restore call to locale.bindtextdomain() for GtkBuilder
Apparently some Linuxes require it for GtkBuilder to find the localization files. It's not supported on Win32, though, so don't try in that case.

svn: r21488
2013-02-28 18:57:19 +00:00
John Ralls
ca80adeb01 GrampsLocale: Set collation, currency, and calendar to lang only on secondary locale objects.
svn: r21487
2013-02-28 18:57:13 +00:00
John Ralls
4eb3e7c926 GrampsLocale: Fix get_addon_translator path
Add the locale subdirectory.
Also clean out some cruft left over from the old implementation.

svn: r21485
2013-02-28 18:56:59 +00:00
Helge Herz
bf438cddd6 Python less 3.x uses GdkPixbuf.new_subpixbuf instead dkPixbuf.subpixbuf issue 6487
svn: r21477
2013-02-27 22:24:14 +00:00
John Ralls
138bbb047b GrampsLocale: Remove all calls to locale.setlocale and locale.bindtextdomain
svn: r21451
2013-02-26 00:16:41 +00:00
John Ralls
07b52e2a11 ConfigManager: Ensure key files are loaded and saved as utf-8
svn: r21447
2013-02-26 00:15:55 +00:00
John Ralls
6f8fc1be58 Work around lack of locale.LC_MESSAGES on some Windows pythons
svn: r21436
2013-02-24 17:38:43 +00:00
John Ralls
c56bd35ce0 GrampsLocale: Correct setting GrampsLocale.languages
Test only first 5 or first 2 characters of the language id against the
list of available translations.

Thanks to Tim Lyons for exposing the error.

svn: r21326
2013-02-09 18:59:20 +00:00
Tim G L Lyons
404c2f154b date.get_start_date has no attribute 'is_valid'
svn: r21292
2013-02-04 18:12:09 +00:00
John Ralls
06ce88cef4 GrampsLocale: Allow for importing older PyICU packages
svn: r21287
2013-02-04 01:42:51 +00:00
Peter Landgren
b225c71885 Fixed a typo LC_MONETARY -> 'LC_MONETARY'.
svn: r21283
2013-02-03 15:30:40 +00:00
John Ralls
a8bbb91d25 GrampsLocale: Fix some oversights in creation of second GrampsLocale
svn: r21282
2013-02-03 02:05:14 +00:00
John Ralls
5f8575241b grampslocale: Pretty up the log messages.
svn: r21281
2013-02-03 02:05:06 +00:00
John Ralls
f8a4ad6cb1 grampslocale.py: Protect against C.UTF-8 not being an installed locale on Linux.
svn: r21280
2013-02-03 01:23:05 +00:00
John Ralls
fd61b21a2d GrampsLocale: Replace locale.strcoll, locale.strxfrm, and conv*_tosrtkey
With GrampsLocale.sort_key (for strxfrm and conv*_tosrtkey) and
GrampsLocale.strcoll.

If ICU is available will use the correct ICU::Collator for the locale,
otherwise falls back to locale.strxfrm -- for which it temporarily
changes the LC_COLLATE locale.

svn: r21275
2013-02-01 22:49:14 +00:00
John Ralls
f238be30ef GrampsLocale: Introduce GrampsLocale attributes currency, calendar, and collate
svn: r21274
2013-02-01 22:48:57 +00:00
John Ralls
0c2263a327 GrampsLocale: Make maclocale.mac_setup_localization() set glocale attributes directly
svn: r21273
2013-02-01 22:48:51 +00:00
John Ralls
ad61ad70a5 GrampsLocale: Extract function __init_from_environment
svn: r21272
2013-02-01 22:48:41 +00:00
Tim G L Lyons
e2f4e39f7e find_file and find_folder do not return null string if the file or folder resp. do not exist (coding typo)
svn: r21267
2013-02-01 17:35:37 +00:00
John Ralls
72051dd488 GrampsLocale: Replace use of get_language_string with GrampsLocale.get_language_dict
Permits sorting by localized language name.
Also hides the language code, which the user doesn't really care about.
Removes get_language_string from libtranslate.py, no longer needed.

svn: r21236
2013-01-27 21:10:17 +00:00
John Ralls
091782abf7 GrampsLocale: Use module-specific logger for grampslocale.py
Fixes double-logging problem reported by Tim Lyons.

svn: r21235
2013-01-27 21:10:09 +00:00
Doug Blank
23c9ce10b9 6364: dead people are shown as alive in narrated web page export
svn: r21219
2013-01-25 12:53:50 +00:00
John Ralls
7fb81b5c21 GrampsLocale: Fix call to member function.
svn: r21186
2013-01-21 15:14:17 +00:00
John Ralls
5e505f2c21 GrampsLocale: Restructure so that multiple GrampsLocale objects can safely be created for different locales
Only the first dependent upon the environment
All may be created with parameters which override environment variables or OS settings.
See the GrampsLocale docstring for details.

svn: r21182
2013-01-21 01:27:29 +00:00
Tim G L Lyons
c91b53f0c4 0005088: Narrated Web Site Report sort order different Windows vs Linux. Initial commit to resolve the issues on Linux and Mac (provided in both cases PyICU is installed). Windows still needs to be tested, and there may still be some other uses of strxfrm (or strcoll) that need to be fixed.
svn: r21175
2013-01-20 15:11:06 +00:00
John Ralls
e920cbfac1 GrampsLocale: Get the language code from the global translation
Instead of probing locale.getlocale() and environment variables

svn: r21151
2013-01-17 19:48:24 +00:00
John Ralls
df46941e73 GrampsLocale: Use the codeset from the singleton translation
Instead of locale.getlocale() or locale.nl_langinfo

svn: r21150
2013-01-17 19:48:14 +00:00
John Ralls
09a875db11 GrampsLocale: Simplify the file-finding functions
Making use of the fact that GrampsLocale now knows what
encoding to use, and noting that filesystems don't use
more than one encoding to write filenames in directories.

Also specify the encoding on some more files

svn: r21148
2013-01-17 19:47:59 +00:00
John Ralls
cc4ec85b4d [Bug 6364] Fix file-opening failures due to unicode content.
svn: r21147
2013-01-17 19:47:44 +00:00
John Ralls
a58ef2b73f GrampsLocale: Replace calls to sys.getfilesystemencoding
On MSWin and OSX, this call always returns the correct
value (utf-8 on OSX, 'mbcs' on MSWin), but on Linux the
return value is bizarrely dependent upon the environment.

Replace it with a GrampsLocale function which returns 'utf-8'
(the correct value for most Linux file systems) regardless of
the environment.

Also replace its use in print and write functions: It's the
encoding of paths in the filesystem, not of the files's content,
nor of the terminal's capabilities. The former is almost
always utf-8 as long as we write the file, the latter is
given by sys.stdout.encoding. Use the 'backslashreplace' error
handler to avoid exceptions when we need to output unicode
text to an ASCII terminal.

svn: r21146
2013-01-17 19:47:36 +00:00
John Ralls
ef7e047b4b [Bug 6222]: Get the addons language list from the primary
GrampsLocale instance.

svn: r21145
2013-01-17 19:47:21 +00:00
John Ralls
ef6892abbd GrampsLocale: Remove ggettext
svn: r21144
2013-01-17 19:46:55 +00:00
John Ralls
d3c2a8a490 Localization: Re-implement localization as a class, GrampsLocale
GrampsLocale is effectively a singleton: An instance is created in
const.py and retrieved everywhere.

Translations are provided via Translations classes, which are derived
from GNUTranslations and NullTranslations to provide extra functions
like sgettext.

svn: r21143
2013-01-17 19:42:11 +00:00
John Ralls
eecf57a0f6 Rename trans.py and mactrans.py to grampslocale.py and maclocale.py
Reflecting discussion on gramps-devel about their affecting more than
just translations.

Provide for a master GrampsLocale instance to be retrieved from
const.py, set by grampsapp.

svn: r21142
2013-01-17 19:41:58 +00:00
Benny Malengier
926dbca98f 6329: Crazy citations after XML import of bacuo from Gramps 3.4.3
svn: r21123
2013-01-15 08:42:50 +00:00
Benny Malengier
1fe37cae6f fix error of revision 20699
svn: r21021
2013-01-07 09:17:16 +00:00
John Ralls
f14b5d8944 Fix up mactrans.py for python3
svn: r21010
2013-01-06 20:40:46 +00:00
Doug Blank
98958cb164 6067: Narrative Web reports people as Living even when they have a deceased event (but without a date because it is unknown)
svn: r21008
2013-01-06 02:31:28 +00:00
Nick Hall
57dc4c0118 Convert filenames to lower case
svn: r20985
2013-01-04 22:29:44 +00:00
Doug Blank
d6214118e2 6274: Tried to use Charts View and receive 'NameError: global name 'gen' is not defined'
svn: r20946
2013-01-03 05:41:01 +00:00
Doug Blank
7242f9d662 4719: Narweb Privacy issue, probably_alive uses spouse birth/death directly
svn: r20935
2013-01-02 03:01:42 +00:00
Doug Blank
91173ba2a8 Bumped trunk to 4.1, updated plugins, requires setup.py build rather than copy of const.py.in, show svn number in version number
svn: r20919
2012-12-31 22:51:11 +00:00
Nick Hall
43b6e62d2d Update translation code to use LOCALE_DIR
svn: r20876
2012-12-29 17:52:17 +00:00
Benny Malengier
0e01b5919e 6231: WARNING: configmanager.py: line 309: WARNING: ignoring key with wrong type
'behavior.autoload'


svn: r20789
2012-12-18 11:50:02 +00:00
Paul Franklin
1c22612f5d for Python files in the "gramps" (only) sub-tree:
1) add SVN svn:keywords "Id" property if it didn't have it
2) add SVN svn:mime-type "text/plain" property if it didn't have it
3) add SVN "Id" line to the file if it had none
4) reformat SVN "Id" line in the file if it needed it


svn: r20708
2012-11-27 04:31:14 +00:00
Benny Malengier
a1591a964c python 3 support, avoid use of unicode
svn: r20699
2012-11-23 17:22:00 +00:00
Jérôme Rapinat
bd28665977 try to update warning log according to new translation builder
svn: r20694
2012-11-22 17:45:36 +00:00
Paul Franklin
28d939cda7 6155: Error when running Detailed Descendant Report
svn: r20674
2012-11-17 21:28:14 +00:00
Benny Malengier
1cad822978 2620: GEPS 031: Python 3 support - 3.2
* fix introduced errors: write of reference in db, check in dbloader on string type
 * working import of xml file in python 3


svn: r20659
2012-11-15 10:28:19 +00:00
Benny Malengier
8b39b80dc8 2620: GEPS 031: Python 3 support - 3.2
round 2 for python 3 support:
* no more cmp, also not in sort and sorted
* bsddb needs bytestring keys
* gtk does not need utf-8 encoded anymore...


svn: r20658
2012-11-15 08:08:31 +00:00
Benny Malengier
bb5fc7cb7c 2620: GEPS 031: Python 3 support - 3.2
This does patch updates Gramps to the 3.2 syntax, it does not yet mean Gramps works with python 3.2
Expect next day commits to fix further issues, but this is the main 2to3 tool created patch changed
where needed to have python 2.7 work. 
Specific issues might be:
  1. next has been changed, must be checked
  2. new division as on the wiki page listed is to do
  3. ...


svn: r20634
2012-11-07 17:53:14 +00:00
Benny Malengier
91e6df28c1 GEPS 026: Replace 'make' for Gramps build
Remove all makefile in gramps code
Still present: make for doc creation and make for webapp


svn: r20499
2012-10-03 08:46:04 +00:00
Benny Malengier
9832e6712e Coding Guidelines: relative import of gen in gen submodule
svn: r20479
2012-10-02 08:28:08 +00:00
Benny Malengier
47a612c36a Code guideline: move to relative import within gen module
svn: r20478
2012-10-01 20:53:08 +00:00
Benny Malengier
326d604365 GEPS 026: Replace 'make' for Gramps build
If we want to use Gramps from the code directory, src should be called gramps to allow import


svn: r20466
2012-09-30 11:55:52 +00:00